| |
- __builtin__.object
-
- Action
- StateManager
- TransactionCallback
- threading.Thread(threading._Verbose)
-
- Daemon
class Action(__builtin__.object) |
|
Action callback.
This class makes it easy to create and register action callbacks by
sub-classing it and implementing cb_action in the derived class. |
|
Methods defined here:
- __init__(self, daemon, actionpoint, log=None, init_args=None, app=None)
- Initialize this object.
The 'daemon' argument should be a Daemon instance. 'actionpoint'
is the name of the tailf:actionpoint to manage. 'log' can be any
log object, and if not set the standard logging mechanism will be
used. 'init_args' may be any object that will be passed into init()
when this object is constructed. 'app' is only used when running
NCS and using the ncs.application module. Lastly, the low-level
function dp.register_action_cbs() will be called.
When using this class together with ncs.application.Application
there is no need to manually initialize this object as it is
done by the Application.register_service() method.
- cb_init(self, uinfo)
- The cb_init callback must always be implemented.
This default implementation will associate a new worker socket
with this callback.
- init(self, init_args)
- Custom initialization.
When registering an action using ncs.application.Application this
method will be called with the 'init_args' passed into the
register_action() function.
- start(self)
- stop(self)
Static methods defined here:
- action(fn)
- Decorator for the cb_action callback.
Only use this decorator for actions of tailf:action type.
Using this decorator alters the signature of the cb_action callback
and passes in maagic.Node objects for input and output action data.
Example of a decorated cb_action:
@Action.action
def cb_action(self, uinfo, name, kp, input, output):
pass
Keyword arguments:
uinfo -- a UserInfo object
name -- the tailf:action name (string)
kp -- the keypath of the action (HKeypathRef)
input -- input node (maagic.Node)
output -- output node (maagic.Node)
- rpc(fn)
- Decorator for the cb_action callback.
Only use this decorator for rpc:s.
Using this decorator alters the signature of the cb_action callback
and passes in maagic.Node objects for input and output action data.
Example of a decorated cb_action:
@Action.rpc
def cb_action(self, uinfo, name, input, output):
pass
Keyword arguments:
uinfo -- a UserInfo object
name -- the rpc name (string)
input -- input node (maagic.Node)
output -- output node (maagic.Node)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Daemon(threading.Thread) |
|
Manage a data provider connection towards ConfD/NCS. |
|
- Method resolution order:
- Daemon
- threading.Thread
- threading._Verbose
- __builtin__.object
Methods defined here:
- __init__(self, name, log=None, ip='127.0.0.1', port=4565, path=None, state_mgr=None)
- Initialize a Daemon object.
The 'name' argument should be unique. It will show up in the
CLI and in error messages. All other arguments are optional.
Argument 'log' can be any log object, and if not set the standard
logging mechanism will be used. Set 'ip' and 'port' to
where your Confd/NCS server is. 'path' is a filename to a unix
domain socket to be used in place of 'ip' and 'port'. If 'path'
is provided, 'ip' and 'port' arguments are ignored.
Daemon supports automatic restarting in case of error if a
state manager is provided using the state_mgr parameter.
- ctx(self)
- Return the daemon context.
- finish(self)
- Stop the daemon thread.
- ip(self)
- Return the ip address.
- load_schemas(self)
- Load schema information into the process memory.
- path(self)
- Return the unix domain socket path.
- port(self)
- Return the port.
- register_trans_cb(self, trans_cb_cls=<class 'confd.dp.TransactionCallback'>)
- Register a transaction callback class.
It's not necessary to call this method. Only do that if a custom
transaction callback will be used.
- run(self)
- Daemon thread processing loop.
Don't call this method explicitly. It handles reading of control
and worker sockets and notifying ConfD/NCS that it should continue
processing by calling the low-level function dp.fd_ready().
If the connection towards ConfD/NCS is broken or if finish() is
explicitly called, this function (and the thread) will end.
- start(self)
- Start daemon work thread.
After registering any callbacks (action, services and such), call
this function to start processing. The low-level function
dp.register_done() will be called before the thread is started.
- wsock(self)
- Return the worker socket.
Data and other attributes defined here:
- INIT_RETRY_INTERVAL_S = 1
Methods inherited from threading.Thread:
- __repr__(self)
- getName(self)
- isAlive(self)
- isDaemon(self)
- is_alive = isAlive(self)
- join(self, timeout=None)
- setDaemon(self, daemonic)
- setName(self, name)
Data descriptors inherited from threading.Thread:
- daemon
- ident
- name
Data descriptors inherited from threading._Verbose:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class StateManager(__builtin__.object) |
|
Base class for state managers used with Daemon |
|
Methods defined here:
- __init__(self, log)
- setup(self, state, previous_state)
- teardown(self, state, finished)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class TransactionCallback(__builtin__.object) |
|
Default transaction callback implementation class.
When connecting data providers to ConfD/NCS a transaction callback
handler must be provided. This class is a generic implementation of
such a handler. It implements the only required callback 'cb_init'. |
|
Methods defined here:
- __init__(self, wsock, log)
- Initialize a TransactionCallback object.
The argument 'wsock' is the connected worker socket and 'log'
is a log object.
- cb_init(self, tctx)
- The cb_init callback must always be implemented.
It is required to prepare for future read/write operations towards
the data source. This default implementation associates a worker
socket with a transaction.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |