platypush.backend.local

class platypush.backend.local.LocalBackend(request_fifo, response_fifo, **kwargs)[source]

Sends and receive messages on two distinct local FIFOs, one for the requests and one for the responses.

You can use this backend either to send local commands to push through Pusher (or any other script), or debug. You can even send command on the command line and read the responses in this way:

# Send the request. Remember: the JSON must be all on one line.
$ cat <<EOF > /tmp/platypush-requests.fifo
{"type": "request", "target": "node_name", "action": "shell.exec", "args": {"cmd":"echo ping"}, "origin": "node_name", "id": "put_an_id_here"}
EOF
$ cat /tmp/platypush-responses.fifo
ping
$
__init__(request_fifo, response_fifo, **kwargs)[source]
Parameters:
  • bus – Reference to the bus object to be used in the backend
  • poll_seconds – If the backend implements a loop method, this parameter expresses how often the loop should run in seconds.
  • kwargs – Key-value configuration for the backend
run()[source]

Starts the backend thread. To be implemented in the derived classes if the loop method isn’t defined.

send_message(msg)[source]

Sends a platypush.message.Message to a node. To be implemented in the derived classes. By default, if the Redis backend is configured then it will try to deliver the message to other consumers through the configured Redis main queue.

Parameters:
  • msg – The message to send
  • queue_name – Send the message on a specific queue (default: the queue_name configured on the Redis backend)