Client interface
A client is any software component interacting with a daemon, in the form of issuing requests, receiving responses to requests, and receiving asynchronous updates of new item values. The Python interface described here makes liberal use of background threads, callbacks in particular can and will arrive from background threads as asynchronous updates arrive. the author of any custom code should not assume that calls arriving via these mechanisms will be serialized or thread-safe to any meaningful degree.
Unlike the Daemon interface, a typical client application will not need subclasses of the classes defined here, they are expected to be used directly, as-is.
Getting started
The mktl.get()
method is the universal entry point to retrieve a
Store
or Item
instance; client configuration is automatically
refreshed if necessary, and the remainder of the connection logic is handled
by the Store
.
All other client operations, such as getting and setting item values, are
handled via the Item
instance.
- mktl.get(store, key=None)
The
get()
method is intended to be the primary entry point for all interactions with a key/value store.The return value is either a cached
Store
orItem
instance. If both a store and a key are specified, the requested item will be returned from the specified store. The same will occur if the sole argument is a store and key name concatenated with a dot (store.KEY). AStore
instance will be returned if the sole argument provided is a store name. Both the store and the key are case-insensitive.If the caller always uses
get()
to retrieve aStore
orItem
they will always receive the same instance of that class. In that sense,get()
is a factory method enforcing a singleton pattern.
Client.Store class
The Store
class is primarily an organizational structure, providing
a dictionary-style interface to retrieve Item
instances.
Client.Item class
The bulk of the client interactions will occur with the Item
class.
In addition to the methods described here an Item
instance can be
used with Python operators, such as addition/concatenation or multiplication.
The behavior of an Item
when used in this fashion will be aligned
with the native Python binary type for the item value; for example, if an
item test.BAR has an integer value 12, test.BAR + 5
will return 17; if
the value is instead the string value ‘12’, the same operation will raise a
TypeError exception.