rsb.patterns¶
Package containing pattern implementations like RPC based on the basic
participants rsb.Listener
and rsb.Informer
.
Code author: jmoringe
Code author: jwienke
Classes
DataFuture () |
Instances of this class are like ordinary Future`s, the only difference being that the :obj:`get method returns the payload of an Event object. |
FullyParallelEventReceivingStrategy () |
An EventReceivingStrategy that dispatches events to multiple handlers in individual threads in parallel. |
Future () |
Objects of this class represent the results of in-progress operations. |
LocalMethod (scope, config, server, name, ...) |
Objects of this class implement and make available methods of a local server. |
LocalServer (scope, config) |
Objects of this class associate a collection of method objects which are implemented by callback functions with a scope under which these methods are exposed for remote clients. |
Method (scope, config, server, name, ...) |
Objects of this class are methods which are associated to a local or remote server. |
RemoteMethod (scope, config, server, name, ...) |
Objects of this class represent methods provided by a remote server. |
RemoteServer (scope, config) |
Objects of this class represent remote servers in a way that allows calling methods on them as if they were local. |
Server (scope, config) |
Objects of this class represent local or remote serves. |
Exceptions
RemoteCallError (scope, method[, message]) |
Errors of this class are raised when a call to a remote method fails for some reason. |
-
exception
rsb.patterns.
RemoteCallError
(scope, method, message=None)¶ Bases:
exceptions.RuntimeError
Errors of this class are raised when a call to a remote method fails for some reason.
Code author: jmoringe
-
getMethod
()¶
-
getScope
()¶
-
args
¶
-
message
¶
-
method
¶
-
scope
¶
-
-
class
rsb.patterns.
LocalMethod
(scope, config, server, name, func, requestType, replyType, allowParallelExecution)¶ Bases:
rsb.patterns.Method
Objects of this class implement and make available methods of a local server.
The actual behavior of methods is implemented by invoking arbitrary user-supplied callables.
Code author: jmoringe
-
activate
()¶
-
deactivate
()¶
-
getConfig
()¶
-
getConnectors
(direction, config)¶
-
getId
()¶
-
getInformer
()¶
-
getListener
()¶
-
getName
()¶
-
getReplyType
()¶
-
getRequestType
()¶
-
getScope
()¶
-
getServer
()¶
-
getTransportURLs
()¶ Returns of list transport URLs describing transport used by the participant.
Returns: Set of transport URLs. Return type: set
-
makeInformer
()¶
-
makeListener
()¶
-
setId
(theId)¶
-
setScope
(scope)¶
-
config
¶
-
id
¶
-
informer
¶
-
listener
¶
-
name
¶
-
replyType
¶
-
requestType
¶
-
scope
¶
-
server
¶
-
-
class
rsb.patterns.
LocalServer
(scope, config)¶ Bases:
rsb.patterns.Server
Objects of this class associate a collection of method objects which are implemented by callback functions with a scope under which these methods are exposed for remote clients.
Code author: jmoringe
Creates a new
LocalServer
object that exposes methods under thersb.Scope
scope
.Parameters: - scope (rsb.Scope) – The scope under which the methods of the newly created server should be provided.
- config (rsb.ParticipantConfig) – The transport configuration that should be used for communication performed by this server.
See also
-
activate
()¶
-
addMethod
(name, func, requestType=<type 'object'>, replyType=<type 'object'>, allowParallelExecution=False)¶ Add a method named
name
that is implemented byfunc
.Parameters: - name (str) – The name of of the new method.
- func – A callable object or a single argument that implements the desired behavior of the new method.
- requestType (types.TypeType) – A type object indicating the type of request data passed to the method.
- replyType – A type object indicating the type of reply data of the method.
- allowParallelExecution (bool) – if set to True, the method will be called fully asynchronously and even multiple calls may enter the method in parallel. Also, no ordering is guaranteed anymore.
Returns: The newly created method.
Return type:
-
deactivate
()¶
-
getConfig
()¶
-
getConnectors
(direction, config)¶
-
getId
()¶
-
getMethod
(name)¶
-
getMethods
()¶
-
getScope
()¶
-
getTransportURLs
()¶ Returns of list transport URLs describing transport used by the participant.
Returns: Set of transport URLs. Return type: set
-
removeMethod
(method)¶
-
setId
(theId)¶
-
setScope
(scope)¶
-
config
¶
-
id
¶
-
methods
¶
-
scope
¶
-
class
rsb.patterns.
Method
(scope, config, server, name, requestType, replyType)¶ Bases:
rsb.Participant
Objects of this class are methods which are associated to a local or remote server. Within a server, each method has a unique name.
This class is primarily intended as a superclass for local and remote method classes.
Code author: jmoringe
Create a new
Method
object for the method namedname
provided byserver
.Parameters: - server – The remote or local server to which the method is associated.
- name (str) – The name of the method. Unique within a server.
- requestType (types.TypeType) – The type of the request argument accepted by the method.
- replyType (types.TypeType) – The type of the replies produced by the method.
-
activate
()¶
-
deactivate
()¶
-
getConfig
()¶
-
getConnectors
(direction, config)¶
-
getId
()¶
-
getInformer
()¶
-
getListener
()¶
-
getName
()¶
-
getReplyType
()¶
-
getRequestType
()¶
-
getScope
()¶
-
getServer
()¶
-
getTransportURLs
()¶ Returns of list transport URLs describing transport used by the participant.
Returns: Set of transport URLs. Return type: set
-
setId
(theId)¶
-
setScope
(scope)¶
-
config
¶
-
id
¶
-
informer
¶
-
listener
¶
-
name
¶
-
replyType
¶
-
requestType
¶
-
scope
¶
-
server
¶
-
class
rsb.patterns.
RemoteMethod
(scope, config, server, name, requestType, replyType)¶ Bases:
rsb.patterns.Method
Objects of this class represent methods provided by a remote server. Method objects are callable like regular bound method objects.
Code author: jmoringe
-
activate
()¶
-
async
(arg=None)¶ Call the method asynchronously with argument
arg
, returning aFuture
instance that can be used to retrieve the result.If
arg
is an instance ofEvent
, the result of the method call is anEvent
containing the object returned by the remote method as payload. Ifarg
is of any other type, the result is the payload of the method call is the object that was returned by the remote method.The call to this method returns immediately, even if the remote method did produce a result yet. The returned
Future
instance has to be used to retrieve the result.Parameters: arg – The argument object that should be passed to the remote method. A converter has to be available for the type of arg
.Returns: A Future
orDataFuture
instance that can be used to check the success of the method call, wait for the result and retrieve the result.Return type: Future or DataFuture Raises: RemoteCallError
– If an error occurs before the remote was invoked.See also
__call__
Examples
>>> myServer.echo.async('bla') <Future running at 3054cd0> >>> myServer.echo.async('bla').get() 'bla' >>> myServer.echo.async(Event(scope=myServer.scope, ... data='bla', type=str)).get() Event[id = ..., data = 'bla', ...]
-
deactivate
()¶
-
getConfig
()¶
-
getConnectors
(direction, config)¶
-
getId
()¶
-
getInformer
()¶
-
getListener
()¶
-
getName
()¶
-
getReplyType
()¶
-
getRequestType
()¶
-
getScope
()¶
-
getServer
()¶
-
getTransportURLs
()¶ Returns of list transport URLs describing transport used by the participant.
Returns: Set of transport URLs. Return type: set
-
makeInformer
()¶
-
makeListener
()¶
-
setId
(theId)¶
-
setScope
(scope)¶
-
config
¶
-
id
¶
-
informer
¶
-
listener
¶
-
name
¶
-
replyType
¶
-
requestType
¶
-
scope
¶
-
server
¶
-
-
class
rsb.patterns.
RemoteServer
(scope, config)¶ Bases:
rsb.patterns.Server
Objects of this class represent remote servers in a way that allows calling methods on them as if they were local.
Code author: jmoringe
Create a new
RemoteServer
object that provides its methods under the scopescope
.Parameters: - scope (rsb.Scope) – The common super-scope under which the methods of the remote created server are provided.
- config (rsb.ParticipantConfig) – The configuration that should be used by this server.
See also
-
activate
()¶
-
addMethod
(method)¶
-
deactivate
()¶
-
ensureMethod
(name)¶
-
getConfig
()¶
-
getConnectors
(direction, config)¶
-
getId
()¶
-
getMethod
(name)¶
-
getMethods
()¶
-
getScope
()¶
-
getTransportURLs
()¶ Returns of list transport URLs describing transport used by the participant.
Returns: Set of transport URLs. Return type: set
-
removeMethod
(method)¶
-
setId
(theId)¶
-
setScope
(scope)¶
-
config
¶
-
id
¶
-
methods
¶
-
scope
¶
-
class
rsb.patterns.
Server
(scope, config)¶ Bases:
rsb.Participant
Objects of this class represent local or remote serves. A server is basically a collection of named methods that are bound to a specific scope.
This class is primarily intended as a superclass for local and remote server classes.
Code author: jmoringe
Create a new
Server
object that provides its methods under thersb.Scope
scope
.Parameters: - scope (rsb.Scope) – The under which methods of the server are provided.
- config (rsb.ParticipantConfig) – The transport configuration that should be used for communication performed by this server.
-
activate
()¶
-
addMethod
(method)¶
-
deactivate
()¶
-
getConfig
()¶
-
getConnectors
(direction, config)¶
-
getId
()¶
-
getMethod
(name)¶
-
getMethods
()¶
-
getScope
()¶
-
getTransportURLs
()¶ Returns of list transport URLs describing transport used by the participant.
Returns: Set of transport URLs. Return type: set
-
removeMethod
(method)¶
-
setId
(theId)¶
-
setScope
(scope)¶
-
config
¶
-
id
¶
-
methods
¶
-
scope
¶