apicrud.service_registry¶
service_registry.py
- Service Registry
Services or the UI discover one another through this service registry. Each microservice instance submits its identity and capabilities to this central registry, implemented as expiring redis keys which are updated at a fixed frequency. Encryption provides modest protection against injection attacks.
created 8-may-2020 by richb@instantlinux.net
Classes
|
Service registry |
-
class
apicrud.service_registry.
ServiceRegistry
(ttl=None, redis_conn=None)¶ Service registry
-
db_session
¶ existing db session
- Type
obj
-
ttl
¶ how long to cache instance’s registration
- Type
int
-
redis_conn
¶ connection to redis
- Type
obj
-
find
(service_name=None)¶ Finds one or all services
- Parameters
service_name (str) – a service, or None for all
- Returns
- dict - instances (list of registered services)
url_map (public url for each top-level resource)
-
register
(resource_endpoints, service_name=None, instance_id='build-11714235-project-613164-apicrud', tcp_port=None)¶ register an instance serving a list of endpoints
- Parameters
resource_endpoints (list of str) – controller endpoints served
service_name (str) – microservice name
instance_id (str) – unique ID of instance
tcp_port (int) – port number of service
-
static
update
()¶ background function to update registration at the defined interval from local memory cache, until the instance terminates.
-