Sending

class p2p0mq.app.client.Sender(*args, **kwargs)[source]

A thread that sends requests and information to peers.

These are “clients” according to the [zmq_curve](http://api.zeromq.org/4-1:zmq-curve) which states that: > A socket using CURVE can be either client or server, > at any moment, but not both. > The role is independent of bind/connect direction.

To become a CURVE client, the local peer sets the ZMQ_CURVE_SERVERKEY option with the long-term public key of the server it intends to connect to, or accept connections from, next. The local peer then sets the ZMQ_CURVE_PUBLICKEY and ZMQ_CURVE_SECRETKEY options with its client long-term key pair.

The sender provides three queues: - fast (sends all available messages every loop); - medium (sends oldest message of each peer every loop); - slow (sends oldest overall message;one message per loop).

connect_peers()[source]

Called during the execution step to connect to peers.

create()[source]

Called at thread start to initialize the state.

enqueue(message, priority=0)[source]

Adds one or more messages to internal queue to be send later.

enqueue_all(requests=None, replies=None, routed=None)[source]

Enqueues all kinds of messages.

enqueue_fast(message)[source]

Adds one or more messages to internal fast queue to be send later.

enqueue_medium(message)[source]

Adds one or more messages to internal medium queue to be send later.

enqueue_slow(message)[source]

Adds one or more messages to internal slow queue to be send later.

execute()[source]

Called to execute the main part of the thread.

We’re simply looping through our queues and ask each one to give us some messages that we then try to send.

execute_queue(queue)[source]

Called during the execution step to send messages from a queue.

The method takes one or more messages from a queue, encodes the message and sends it to the socket.

send_message(message)[source]

Encode and send a single message.

If the socket throws an error: - we check if the time to live has expired, in which case we drop the message and inform the handler. - we tell the handler (Concern class) that we could not send it ( by default the handler will give us back the same message to put it back in the queue until the message expires).

Returns:The message to be enqueued or None. This is not a (PRIORITY, message) format.
terminate()[source]

Called at thread end to free resources.