updated readme for service discovery

This commit is contained in:
Tom Gardham-Pallister 2017-02-06 22:03:48 +00:00
parent 0a66051b92
commit 201b470cb2
2 changed files with 52 additions and 1 deletions

View File

@ -162,6 +162,44 @@ This means that when Ocelot tries to match the incoming upstream url with an ups
evaluation will be case sensitive. This setting defaults to false so only set it if you want evaluation will be case sensitive. This setting defaults to false so only set it if you want
the ReRoute to be case sensitive is my advice! the ReRoute to be case sensitive is my advice!
## Service Discovery
Ocelot allows you to specify a service discovery provider and will use this to find the host and port
for the downstream service Ocelot is forwarding a request to. At the moment this is only supported in the
GlobalConfiguration section which means the same service discovery provider will be used for all ReRoutes
you specify a ServiceName for at ReRoute level.
In the future we can add a feature that allows ReRoute specfic configuration.
At the moment the only supported service discovery provider is Consul. The following is required in the
GlobalConfiguration. The Provider is required and if you do not specify a host and port the Consul default
will be used.
"ServiceDiscoveryProvider":
{
"Provider":"Consul",
"Host":"localhost",
"Port":8500
}
In order to tell Ocelot a ReRoute is to use the service discovery provider for its host and port you must add the
ServiceName and load balancer you wish to use when making requests downstream. At the moment Ocelot has a RoundRobin
and LeastConnection algorithm you can use. If no load balancer is specified Ocelot will not load balance requests.
{
"DownstreamPathTemplate": "/api/posts/{postId}",
"DownstreamScheme": "https",
"UpstreamTemplate": "/posts/{postId}",
"UpstreamHttpMethod": "Put",
"ServiceName": "product"
"LoadBalancer": "LeastConnection"
}
When this is set up Ocelot will lookup the downstream host and port from the service discover provider and load balancer
requests across any available services.
## Authentication ## Authentication
Ocelot currently supports the use of bearer tokens with Identity Server (more providers to Ocelot currently supports the use of bearer tokens with Identity Server (more providers to
@ -389,3 +427,4 @@ that isnt available is annoying. Let alone it be null.
You can see what we are working on [here](https://github.com/TomPallister/Ocelot/projects/1) You can see what we are working on [here](https://github.com/TomPallister/Ocelot/projects/1)

View File

@ -80,12 +80,24 @@
# the caching a lot. # the caching a lot.
"FileCacheOptions": { "TtlSeconds": 15 }, "FileCacheOptions": { "TtlSeconds": 15 },
# The value of this is used when matching the upstream template to an upstream url. # The value of this is used when matching the upstream template to an upstream url.
"ReRouteIsCaseSensitive": false "ReRouteIsCaseSensitive": false,
# Tells Ocelot the name of the service it is looking when making requests to service discovery
# for hosts and ports
"ServiceName": "product"
# Tells Ocelot which load balancer to use when making downstream requests.
"LoadBalancer": "RoundRobin"
}, },
# This section is meant to be for global configuration settings # This section is meant to be for global configuration settings
"GlobalConfiguration": { "GlobalConfiguration": {
# If this is set it will override any route specific request id keys, behaves the same # If this is set it will override any route specific request id keys, behaves the same
# otherwise # otherwise
"RequestIdKey": "OcRequestId", "RequestIdKey": "OcRequestId",
# If set Ocelot will try and use service discovery to locate downstream hosts and ports
"ServiceDiscoveryProvider":
{
"Provider":"Consul",
"Host":"localhost",
"Port":8500
}
} }
} }