Service

class Cauldron.base.client.Service[source] [edit on github]

Bases: Cauldron.base.core._BaseService

A client-side KTL service object.

Parameters:
  • name – The KTL service name.
  • populate (bool) – Whether to pre-populate this KTL service with all of the known keys.

Services provide a dictionary-like access interface to KTL:

>>> svc = Service('myktl')          
>>> svc['mykey']                    
<Keyword service=myktl name=mykey>

Using dictionary indexing always returns a Keyword object.

Methods Summary

has_key(keyword) alias for has_keyword()
has_keyword(keyword) Determines if this service has a keyword.
heartbeat(keyword[, period]) Identify keyword (either a keyword name, or a Keyword instance) as a heartbeat keyword for this Service.
keywords() List all keywords available in this Service instance.
populated() Returns a list of all keywords (as keyword names) that are instantiated as Keyword instances within this Service instance.
read(keyword, **kwargs) Read a keyword, passes through to the keyword implementation’s Keyword.read().
shutdown() An explicity shutdown method.
write(keyword, value, **kwargs) Write a keyword value, passes through to the keyword implementation’s Keyword.write().

Methods Documentation

has_key(keyword)[source] [edit on github]

alias for has_keyword()

has_keyword(keyword)[source] [edit on github]

Determines if this service has a keyword.

keyword can be either a Keyword instance, or a case-insensitive string.

This is an abstract method. Backends must implement this method

heartbeat(keyword, period=5)[source] [edit on github]

Identify keyword (either a keyword name, or a Keyword instance) as a heartbeat keyword for this Service. A heartbeat keyword should broadcast regularly to indicate that the KTL service is functional. period should be set to the maximum expected interval (in seconds) between heartbeat broadcasts.

All hearbeats are monitored by a background FirstResponder thread that wakes up according to the most imminent expiration of any heartbeat’s set period. If the heartbeat does not update within period seconds, an external check will be made to see whether the service is responding. If it is, and local broadcasts have not resumed, all Service instances corresponding to the affected KTL service will be resuscitated. See the FirstResponder class and Paramedic.resuscitate() for details.

Multiple heartbeats may be specified for a single Service instance. This is desirable if distinct dispatchers provide subsets of the keywords within a single KTL service. The failure of any heartbeat will trigger a full resuscitate operation; no attempt is made to distinguish between Keyword instances serviced by distinct dispatchers.

Warning

heartbeat is not implemented in the Cauldron version of the KTL API.

keywords()[source] [edit on github]

List all keywords available in this Service instance.

This is an abstract method. Backends must implement this method

populated()[source] [edit on github]

Returns a list of all keywords (as keyword names) that are instantiated as Keyword instances within this Service instance. A Keyword instance is not created until it is deliberately requested.

read(keyword, **kwargs)[source] [edit on github]

Read a keyword, passes through to the keyword implementation’s Keyword.read().

shutdown()[source] [edit on github]

An explicity shutdown method.

write(keyword, value, **kwargs)[source] [edit on github]

Write a keyword value, passes through to the keyword implementation’s Keyword.write().