|
Methods defined here:
- __init__(self, settings, peers)
- Constructor for SimpleSyncClient
settings The settings to use for this client
peers The upstream peers to use
- handleAnswer(self, answer, answer_connkey, state)
- Dispatches an answer to threads waiting for it.
- sendRequest(self, request)
- Send a request and wait for an answer.
request The request to send
The answer to the request. Null if there is no answer (all peers
down, or other error)
- start(self)
- Starts this client. The client must be started before sending
requests. Connections to the configured upstream peers will be
initiated but this method may return before they have been
established.
See also: NodeManager.waitForConnection
Methods inherited from diameter.node.NodeManager.NodeManager:
- answer(self, answer, connkey)
- Answer a request.
The answer is sent to the connection. If the connection has been
lost in the meantime it is ignored.
answer The answer message.
connkey The connection to send the answer to.
Raises:
NotARequestError If the answer has the R bit set in the header.
- forwardAnswer(self, answer, connkey)
- Forward an answer.
Forward the answer to to the specified connection. The answer will
automatically get a route-record added. This method is meant to be
called from handleAnswer().
answer The answer to forward
connkey The connection to use
Raises:
NotAnAnswerError
If the answer has the R bit set in the header.
NotProxiableError
If the answer does not have the P bit set in the header. This
indicates that there is something completely wrong with either
the message, the peer or your application.
StaleConnectionError
If the ConnectionKey refers to a lost connection.
- forwardRequest(self, request, connkey, state)
- Forward a request.
Forward the request to the specified connection. The request will
automatically get a route-record added if not already present.
This method is meant to be called from handleRequest().
request The request to forward
connkey The connection to use
state A state object that will be passed to handleAnswer()
when the answer arrives. You should remember the ingoing
connection and hop-by-hop identifier
Raises:
NotARequestError
If the request does not have the R bit set in the header.
NotProxiableError
If the request does not have the P bit set in the header.
StaleConnectionError
If the ConnectionKey refers to a lost connection.
- handleRequest(self, request, connkey, peer)
- Handle a request.
This method is called when a request arrives. It is meant to be
overridden by a subclass. This implementation rejects all requests.
Please note that the handleRequest() method is called by the
networking thread and messages from other peers cannot be received
until the method returns. If the handleRequest() method needs to do
any lengthy processing then it should implement a message queue,
put the message into the queue, and return. The requests can then
be processed by a worker thread pool without stalling the
networking layer.
request The incoming request.
connkey The connection from where the request came.
peer The peer that sent the request. This is not the
originating peer but the peer directly connected to us
that sent us the request.
- handle_connection(self, connkey, peer, updown)
- Handle a a connection state change.
If the connection has been lost this implementation calls
handleAnswer(null,...) for outstanding requests on the connection.
Subclasses should not override this method.
- handle_message(self, msg, connkey, peer)
- Handle an incoming message.
This implementation calls handleRequest(), or matches an answer to
an outstanding request and calls handleAnswer().
Subclasses should not override this method.
- sendRequest_1(self, request, connkey, state)
- Initiate a request.
A request initiated by this node is sent to the specified connection.
request The request.
connkey The connection to use.
state A state object that will be passed to handleAnswer() when
the answer arrives.
Raises:
NotARequestError
If the request does not have the R bit set in the header.
StaleConnectionError
If the ConnectionKey refers to a lost connection.
- sendRequest_any(self, request, peers, state)
- Sends a request.
The request is sent to one of the peers and an optional state
object is remembered. Please note that handleAnswer() for this
request may get called before this method returns. This can happen
if the peer is very fast and the OS thread scheduler decides to
schedule the networking thread.
request The request to send.
peers The candidate peers
state A state object to be remembered. This will be passed to
the handleAnswer() method when the answer arrives.
Raises:
NotARequestError
If the request does not have the R bit set in the header.
NotRoutableError
If the message could not be sent to any of the peers.
- stop(self, grace_time=0)
- Stops the embedded Node and call handleAnswer() with null messages
for outstanding requests.
- waitForConnection(self, timeout=None)
- Waits until at least one connection to a peer has been established
and capability-exchange has finished.
|