oio.conscience package
Submodules
oio.conscience.agent module
-
class
oio.conscience.agent.
ConscienceAgent
(conf)[source] Bases:
oio.common.daemon.Daemon
-
init_watchers
(services)[source]
-
load_services
()[source]
-
run
(*args, **kwargs)[source]
-
stop
()[source]
-
stop_watchers
()[source]
-
-
class
oio.conscience.agent.
ServiceWatcher
(conf, service, **kwargs)[source] Bases:
object
-
check
()[source] Perform the registered checks on the service until any of them fails of the end of the list is reached.
-
get_stats
()[source] Update service definition with all configured stats
-
init_checkers
(service)[source]
-
init_stats
(service)[source] Initialize service stat fetchers
-
register
()[source]
-
start
()[source]
-
stop
()[source]
-
watch
()[source]
-
-
oio.conscience.agent.
load_modules
(group_name)[source]
oio.conscience.client module
-
class
oio.conscience.client.
ConscienceClient
(conf, service_id_max_age=60, **kwargs)[source] Bases:
oio.common.client.ProxyClient
Conscience client. Some calls are actually redirected to LbClient.
-
all_services
(type_, full=False, **kwargs)[source] Get the list of all services of a specific type.
Parameters: - type (str) – the type of services to get (ex: ‘rawx’)
- full – whether to get all metrics for each service
Returns: the list of all services of the specified type
Return type: list of dict
-
deregister
(service_definitions, **kwargs)[source]
-
flush
(srv_type)[source]
-
get_service_definition
(srv_type, srv_id, score=None, tags=None)[source]
-
info
()[source]
-
local_services
()[source]
-
lock_score
(srv_or_list)[source] Lock the score of a service.
Parameters: srv_or_list (dict or list of dict.) – dictionary containing: - ‘addr’: the service address, - ‘type’: the service type, - ‘score’: optional, the score to set the service to.
-
next_instance
(pool, **kwargs)[source] Get the next service instance from the specified pool
-
next_instances
(pool, **kwargs)[source] Get the next service instances from the specified pool.
Parameters: - size (int) – number of services to get
- slot (str) – comma-separated list of slots to poll
-
poll
(pool, **kwargs)[source] Get a set of services from a predefined pool.
Parameters: - avoid (list) – service IDs that must be avoided
- known (list) – service IDs that are already known
-
register
(service_definitions, **kwargs)[source]
-
resolve
(srv_type, service_id)[source]
-
resolve_service_id
(service_type, service_id, check_format=True)[source] Returns: Service address corresponding to the service ID
-
resolve_url
(service_type, url)[source] Returns: Resolved URL of a service using a service ID
-
service_types
()[source]
-
unlock_score
(srv_or_list)[source] Unlock the score of a service, let the Conscience compute it.
Parameters: srv_or_list (dict or list of dict.) – dictionary containing: - ‘addr’: the service address, - ‘type’: the service type,
-
-
class
oio.conscience.client.
LbClient
(conf, **kwargs)[source] Bases:
oio.common.client.ProxyClient
Simple load balancer client
-
create_pool
(pool, targets, force=False, options=None, **kwargs)[source] Create a service pool on the local proxy.
Parameters: - pool (str) – a name for the pool
- targets – a list of tuples like (1, “rawx-usa”, “rawx”, …)
- force – if the pool already exists, overwrite it
- options (dict) – options for the pool
Raises: Conflict – if a pool with same name already exists
-
next_instance
(pool, **kwargs)[source] Get the next service instance from the specified pool
-
next_instances
(pool, size=None, **kwargs)[source] Get the next service instances from the specified pool.
Parameters: size (int) – number of services to get
-
poll
(pool, **kwargs)[source] Get a set of services from a predefined pool.
Parameters: - avoid (list) – service IDs that must be avoided
- known (list) – service IDs that are already known
-