Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Health service instances watcher #10

Merged
merged 2 commits into from
Feb 1, 2019

Conversation

jakubdyszkiewicz
Copy link
Contributor

Solves #9
Adds ability to watch healthy service instances.

I extracted requiredValue function to class otherwise I'd have to duplicate it.

The response from /v1/catalog/service/ is different than /v1/health/service/

The /v1/catalog/service/ response:

[
{
    "ID": "4fbf9ea0-c9a8-a0c5-2c84-6509c0da8639",
    "Node": "localhost",
    "Address": "127.0.0.1",
    "Datacenter": "dc1",
...
    "ServiceID": "sample_service_ip_port",
    "ServiceName": "sample_service",
    "ServiceTags": [
      "tag1"
    ],
    "ServiceAddress": "127.0.0.1",
...
    "ServicePort": 8080,
...
  }
]

The /v1/health/service/ response:

[
{
    "Node": {
      ...
    },
    "Service": {
      "ID": "sample_service_ip_port",
      "Service": "sample_service",
      "Tags": [
        "tag1"
      ],
      "Address": "127.0.0.1",
      "Meta": null,
      "Port": 8080,
      ...
    },
    "Checks": [
      ...
    ]
  }
]

(I ... non important part of the responses)

Because of the different responses, I had to create another JsonDecoder.

The test is not perfect. The new PollingConditions can caught registration of healthy service before unhealthy one, but otherwise I'd have to wait arbitrary time which I did not want to do.

@jakubdyszkiewicz jakubdyszkiewicz merged commit 39ed3d7 into master Feb 1, 2019
@jakubdyszkiewicz jakubdyszkiewicz deleted the health_service_instances branch February 1, 2019 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants