Package: envoxy
Envoxy Platform FrameworkThe Envoxy is a different kind of API REST framework and application daemon, we are trying to use all the best tools and technics together getting all their power and performance to be able to have all the platform running in one unique framework allowing communications and task distribution with:Zapata using (ZeroMQ / UPnP);RabbitMQ using (MQTT / AMQP);Celery;CouchDB;PostgreSQL;Build envoxyd (Envoxy Daemon) and envoxy python package:What isenvoxyd? It is the process daemon using embeded uWSGI customized to be able to boot our modules using theenvoxystructure and API's.$ make installor using docker$ docker build -t envoxy .Steps during the build processsInstall dependenciesDelete previous virtualenv dir if exists (/opt/envoxy)Create clean virtualenv (/opt/envoxy) with python3.6 version and activateGive current user permissions to virtualenv dirInstall envoxy:python setup installPrepare envoxyd files:Delete src dir (vendors/src)Create envoxyd src dir and make a clean copy o uWSGICopy envoxyd files to customize uWSGIInstall envoxyd:python setup installPrepare packages to pypi repository$ make packagesSteps during the packaging processsInstall ProcessCreate a Source distribution for both packages:python3 setup.py sdist bdist_wheelPublish to pypi repositoryOn project root forenvoxyand ./vendors dir forenvoxydMake surebuilddir was createdbuilddir must contain a.whland.tar.gzof the current versionenvoxy-0.0.2-py3-none-any.whl
envoxy-0.0.2.tar.gzUpload current package using twine command and enter your credentials for the account you registered on the real PyPI.$ twine upload dist/*Run envoxyd$ envoxyd --http :8080 --set conf=/path/to/confs/envoxy.jsonHow to use envoxyCreate a new project$ envoxy-cli --create-project --name my-containerHow to build envoxy with Docker$ docker build --no-cache -t envoxy-ubuntu:20.04 -f envoxy-ubuntu.Dockerfile .
$ docker build -t envoxy .Use an existent project path as volume$ docker run -it -d -p 8080:8080 -v /path/to/project:/home/envoxy -v /path/to/plugins:/usr/envoxy/plugins envoxyPostgreSQL connector samplesSelect Queryfrom envoxy import pgsqlc

result = pgsqlc.query(
    "db_name",
    "select * from sample_table where id = 1;"
)Insert statement and Transaction blockfrom envoxy import pgsqlc

with pgsqlc.transaction('db_name') as db_conn:

    r = db_conn.query(
        sql="select * from sample_table limit 2"
    )

    db_conn.insert('sample_table2', {
        "field1": "test",
        "field2": "test",
        "id": 1
    })all inserts statements must be placed inside a transaction blockCouchDB connector samplesFindvalid selectors:eq, gt, gte, lt, ltefields: if defined will only return this fields, otherwise will return all fieldsfrom envoxy import couchdbc

perms = couchdbc.find(
    db="server_key.db_name",
    fields=["id", "field2"]
    params={
        "id": "1234"
        "field1__gt": "2345"
    }
)GetGet the document by idfrom envoxy import couchdbc

perms = couchdbc.get(
    "005r9odyj91dw0y1ho32lvzh5r2avzngvrouyj",
    db="server_key.db_name",
)Redis connector samplesGet valuefrom envoxy import redisc

redisc.get(
    "server_key",
    "my_key"
)

redisc.set(
    "server_key",
    "my_key",
    {
        "a": 1,
        "b": 2
    }
)

# for more operations get raw client
client = redisc.client('server_key')

client.hgetall('my_hash')MQTT connector samplesPublishfrom envoxy import mqttc

mqttc.publish(
    'server_key',
    '/v3/topic/channel',
    { "data": "test" },
    no_envelope=True)Subscribefrom envoxy import mqttc

mqttc.subscribe(
    'server_key',
    '/v3/topic/channels/#',
    callback
)on_eventfrom envoxy import on
from envoxy.decorators import log_event

@on(endpoint='/v3/topic/channels/#', protocols=['mqtt'], server='server_key')
class MqttViewCtrl(View):

    @log_event
    def on_event(self, data, **kwargs):

        do_stuff(data)clientfrom envoxy.mqtt.client import Client as MqttClient

credentials = {
    "client_id": ":client_id"
    "access_token": ":access_token"
}

conf = {
    "myserver": {
        "bind": "mqtt://localhost:8000",
        "cert_path": "/usr/lib/ssl/certs/ca-certificates.crt"
    }
}

mqtt_client = MqttClient(conf, credentials=credentials)
mqtt_cient.publish(
    "myserver",
    "/v3/topic/channel",
    { "data": "test" }
)