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

how to use consul in microdot? #141

Open
quaider opened this issue Feb 28, 2018 · 2 comments
Open

how to use consul in microdot? #141

quaider opened this issue Feb 28, 2018 · 2 comments

Comments

@quaider
Copy link

quaider commented Feb 28, 2018

I have downloaded the GpuService sample, and then change some Environments, but got some error running GpuService.Client

// an empty file loadPaths.json
Environment.SetEnvironmentVariable("GIGYA_CONFIG_ROOT", @"D:\test\dotnet\microdot-samples\GpuService\");
Environment.SetEnvironmentVariable("ENV", "dev");
// consul
Environment.SetEnvironmentVariable("CONSUL", "127.0.0.1:8500");

consul service defination

{
  "service": {
    // can not find a way to change service name(default to GpuService-)
    "name": "GpuService-dev",
    "port": 10000
  }
}

errors

System.AggregateException: One or more errors occurred. ---> Gigya.Common.Contra
cts.Exceptions.EnvironmentException: Query not exists on Consul. See tags for de
tails.; requestedService=GpuService-dev, consulAddress=http://127.0.0.1:8500/, r
equestTime=0001-01-01 00:00:00.000, requestLog=, responseLog=, queryDefined=Fals
e, consulError=

is there any documents i can refer to?

@bronsh
Copy link
Contributor

bronsh commented Feb 28, 2018

Unfortunately, the documentation about discovery is not ready yet.

In short, there are two ways we support for calling Consul.

The first one is using Consul Queries - it executes a Consul query which its name is a combination of the service name and environment (for example: "GpuService-dev").
It is using the following api: {ConsulAddress}/v1/query/{ServiceName-env}/execute?dc={DataCenter}
It calls it every second (by default), to follow up changes.
This way is the default one, but it is going to be deprecated in the future.

The second way is making use of two Consul apis: key-value and health.
It first searches for this service at key-value store, calling this api:
{ConsulAddress}/v1/kv/service?dc={DataCenter}&keys
searching for a key named "service/{ServiceName-env}"
Then it calls this api:
{ConsulAddress}/v1/health/service/{ServiceName-env}?dc={DataCenter}&passing
In the service's tags, it searches for a tag starting with "version:", which states what is the current service version (The service may be deployed on more than one node, and it may contain different version on different nodes). Only nodes which have a version tag with the relevant version will be returned.
The call to these apis on done by long-polling, so it gets notification when changes occured, with no need to call it every second in order to follow up changes.
This way is better for performance issues, although it is more complicated for implementation.

You can configure how to use Consul by defining the following configuration entry: Consul.LongPolling
Its default value is "false", which means using the first way. Changing it to "true" will make it use the second way.
For more information about configuration, see here: https://github.com/gigya/microdot/wiki/Configuration-Repository

@Allon-Guralnek
Copy link
Contributor

Allon-Guralnek commented Feb 28, 2018

The issue in the samples was fixed by the following pull request:

gigya/microdot-samples#5

But it was merged into the branch 1_Basic_Gpu_Service. Try pulling that branch.

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

No branches or pull requests

3 participants