Skip to content

Conversation

@johannesduesing
Copy link
Contributor

Reason for this PR
We recently added support for the reverse-proxy Traefik to the registry. The setup with Traefik allows users and applications to connect to instances deployed inside a docker container. Instead of directly connecting to the requested instance, the users / applications can connect to the Traefik-Host, and specify the additional header Host: <unique-host-string>, which will relay them to their actual target.

The WebApp has to decide whether or not it can connect using IP and Port (when both instances are inside the Docker network, or when the WebApi is outside Docker) or using Traefik (when WebApi is inside Docker network and WebApp is not).

Changes in this PR

  • Adapted instance model according to changes in registry. There now is an optional field TraefikConfig which contains the unique host string assigned to the instance by Traefik.
  • Implemented logic that decides whether or not is has to use Traefik when calling the WebApi, and creates a corresponding HttpRequest
  • Fixed a codestyle issue i missed in the last PR Adapted registry interface to newest API version #26 (uppercase variable name)

@johannesduesing johannesduesing self-assigned this Feb 7, 2019
@ghost ghost added the review label Feb 7, 2019
@johannesduesing
Copy link
Contributor Author

Regarding the codacy report on the usage of get on an option type: I do not think this is a problem, because there is an transitive isDefined check in the enclosing if-statement (see snippet below).

val apiInDocker = configuration.webApiInstance.traefikConfiguration.isDefined
if(apiInDocker && !insideContainer) {
val traefikHost = configuration.webApiInstance.traefikConfiguration.get.proxyUri
val apiHostName = configuration.webApiInstance.traefikConfiguration.get.hostName
//We are outside docker and target is inside -> Need to call traefik
HttpRequest(method, addHttpProtocolIfNotExist(traefikHost) + path, Seq(Host(apiHostName)))
} else {

@bhermann bhermann merged commit 8695cf8 into develop Feb 15, 2019
@ghost ghost removed the review label Feb 15, 2019
@bhermann bhermann deleted the feature/traefikIntegration branch February 15, 2019 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants