The gemstone.discovery module¶
Discovery strategies¶
- class
gemstone.discovery.
BaseDiscoveryStrategy
[source]¶Base class for service discovery strategies.
locate
(name)[source]¶Attempts to locate a microservice with the given name. If no such service exists, must return
None
Parameters: name – The name of the microservice to be located Returns: a list of str with the URLs where a microservice with the given name can be found.
ping
(name, location, **kwargs)[source]¶Pings the service registry as defined by the implemented protocol with the necessary information about the service location.
Parameters:
- name – The name of the microservice
- location – The HTTP location of the microservice, where it can be accessed (multiple microservices might have the same location, for example when they are deployed behind a reverse proxy)
Returns:
Caches¶
- class
gemstone.discovery.
ServiceDiscoveryCache
(cache_lifetime_in_seconds)[source]¶Service discovery cache that keeps entries in memory for a constant period of time.
Example usage:
class MyMicroService(MicroService): # ... service_registry_cache = ServiceDiscoveryCache(60) # keeps entries for one minute # ...
Parameters: cache_lifetime_in_seconds – int that specifies the cache entry lifetime