Skip to main content

Client library for scirocco proyect.

Project description

# Scirocco Pyclient
[![Build Status](](

This is a handy library to interact with the [scirocco-server]( project. If you dont know about it , please read first that project docs.

## Installation

This client library has two main install methods.

#### From source:
git clone
python3 install

#### From pip3:
pip3 install scirocco-pyclient

## Using the library

#### The response object

Every operation in this client will return the same [response object](
, representing the state of the operation at system_data attribute as well the resultant message representation in
message_data attribute.

#### Instantiating the client

For use the library you must instantiate the HTTPClient by passing three params.
Respectively they are scirocco-server endpoint (take care about http/https schema),
your pre-stablished by convention node_id and a the auth token for gain access to that
scirocco-server instance.


from sciroccoclient.httpclient import HTTPClient

scirocco_client = HTTPClient('http://localhost', 'af123', 'DEFAULT_TOKEN')

#### Pushing messages
Pushing messages is simple as this:


scirocco_client.message_queue_push('af123', {"type": "message"})

scirocco_client.message_queue_push('af123', 'message')

binfile = open('file.bin', 'rb').read()
scirocco_client.message_queue_push('af123', binfile, '.bin')
"af123" will become detination node_id as first parameter. At second we
need to send the message itself. If you look at the third optional param,
its a field to store extension or mime type. If you omit it , it will be
setted as same as content-type header. This field is very useful to determine
the extension for some bin data without harder analysis in a pull operation.

The message can be a string , object or binary type.
When a message is pushed , it can be in schedule or pending (default) status.
If the message is being scheduled, it only will be accesible in a 'pull' operation
when schedule_time is reached.

#### Receiving messages

You will receive messages in the same data type as you send it, except for binary
type. You will push binary , and the item is stored as binary , but you will receive
it in base64 representation.

response_object = scirocco_client.message_queue_pull()

# print system headers

# print the message payload.

If no pending messages the client will return None else, it will return
a response object which contains system_data and message_data. The message
will change its status to 'processing', so it cannot be accesible by other
'pull' operation.

#### Confirming messages

When you deal with IPC (inter process comunications) or interdependant operations in different processes,
you need to mark the message as "done" or processed for further operations
in other processes.

You only need to save the previous response object (id in system_data) in its pull operation to confirm
the message by id. For example if we want to confirm '5823a70203c123003de4229b'
message id , the code will be :


#### Review a message

If you only need to watch the status of a message/es ,
call for message_get function, passing as parameter the id of message. Like this.


#### Getting all messages incoming/sended to/by this node

You optionally can pass a first argument to limit the returned results.
Anyway, it will be limited by a server side config parameter.


# Limiting results by 10 (ordered by creation date)


#### Updating a message

As first parameter the id of the message. As second parameter the new data

scirocco_client.message_update_one(id, message)

#### Deleting a message

You must specify as first parameter id of the message to be permanent removed
from the system. Cannot be undone.


#### Deleting all messages

Delete from the system all messages incoming/sended to/by this node.
This operation only may be executed if you want a total reset of the node and
its actions. Cannot be undone.


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for scirocco-pyclient, version v1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size scirocco-pyclient-v1.0.0.linux-x86_64.tar.gz (14.9 kB) File type Dumb Binary Python version any Upload date Hashes View
Filename, size scirocco-pyclient-v1.0.0.tar.gz (9.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page