mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
feat : add pollkube docs
This commit is contained in:
parent
66e05b1fd7
commit
246f2046b3
@ -31,18 +31,10 @@ The example below is taken from the samples folder so please check it if this do
|
|||||||
"DownstreamScheme": "http",
|
"DownstreamScheme": "http",
|
||||||
"UpstreamPathTemplate": "/values",
|
"UpstreamPathTemplate": "/values",
|
||||||
"ServiceName": "downstreamservice",
|
"ServiceName": "downstreamservice",
|
||||||
"UpstreamHttpMethod": [ "Get" ],
|
"UpstreamHttpMethod": [ "Get" ]
|
||||||
"QoSOptions": {
|
|
||||||
"ExceptionsAllowedBeforeBreaking": 3,
|
|
||||||
"DurationOfBreak": 10000,
|
|
||||||
"TimeoutValue": 5000
|
|
||||||
},
|
|
||||||
"FileCacheOptions": { "TtlSeconds": 15 }
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"GlobalConfiguration": {
|
"GlobalConfiguration": {
|
||||||
"RequestIdKey": "OcRequestId",
|
|
||||||
"AdministrationPath": "/administration",
|
|
||||||
"ServiceDiscoveryProvider": {
|
"ServiceDiscoveryProvider": {
|
||||||
"Host": "192.168.0.13",
|
"Host": "192.168.0.13",
|
||||||
"Port": 443,
|
"Port": 443,
|
||||||
@ -53,4 +45,17 @@ The example below is taken from the samples folder so please check it if this do
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
You also can use Ocelot polls kubernetes for latest service information rather than per request. If you want to poll kubernetes for the latest services rather than per request (default behaviour) then you need to set the following configuration.
|
||||||
|
|
||||||
|
"ServiceDiscoveryProvider": {
|
||||||
|
"Host": "192.168.0.13",
|
||||||
|
"Port": 443,
|
||||||
|
"Token": "txpc696iUhbVoudg164r93CxDTrKRVWG",
|
||||||
|
"Namespace": "dev",
|
||||||
|
"Type": "pollkube"
|
||||||
|
"PollingInterval": 100
|
||||||
|
}
|
||||||
|
The polling interval is in milliseconds and tells Ocelot how often to call kubernetes for changes in service configuration.
|
||||||
|
|
||||||
|
Please note there are tradeoffs here. If you poll kubernetes it is possible Ocelot will not know if a service is down depending on your polling interval and you might get more errors than if you get the latest services per request. This really depends on how volatile your services are. I doubt it will matter for most people and polling may give a tiny performance improvement over calling kubernetes per request.
|
||||||
There is no way for Ocelot to work these out for you.
|
There is no way for Ocelot to work these out for you.
|
||||||
|
@ -11,11 +11,9 @@ namespace Ocelot.Provider.Kubernetes
|
|||||||
public static ServiceDiscoveryFinderDelegate Get = (provider, config, name) =>
|
public static ServiceDiscoveryFinderDelegate Get = (provider, config, name) =>
|
||||||
{
|
{
|
||||||
var factory = provider.GetService<IOcelotLoggerFactory>();
|
var factory = provider.GetService<IOcelotLoggerFactory>();
|
||||||
if (config.Type?.ToLower() == "kube")
|
|
||||||
{
|
return GetkubeProvider(provider, config, name, factory);
|
||||||
return GetkubeProvider(provider, config, name, factory);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private static ServiceDiscovery.Providers.IServiceDiscoveryProvider GetkubeProvider(IServiceProvider provider, Configuration.ServiceProviderConfiguration config, string name, IOcelotLoggerFactory factory)
|
private static ServiceDiscovery.Providers.IServiceDiscoveryProvider GetkubeProvider(IServiceProvider provider, Configuration.ServiceProviderConfiguration config, string name, IOcelotLoggerFactory factory)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user