Tiny Framework to build micro services. Currently only support amqp, rpc over amqp and http stream based micro services.
How it works
AMQP
import farine.amqp
class Publish(object):
@farine.amqp.publish(exchange='consume', routing_key='routing_key')
def publish_dummy(self, publish):
"""
:param publish: Send the data through AMQP.
:type publish: farine.amqp.publisher.Publisher
"""
publish({'result':0})
import farine.amqp
class Consume(object):
@farine.amqp.consume(exchange='publish', routing_key='routing_key')
def consume_dummy(self, body, message):
"""
:param body: The message's data.
:type body: dict
:param message: Message class.
:type message: kombu.message.Message
"""
message.ack()
RPC over AMQP
import farine.rpc
class Server(object):
@farine.rpc.method()
def dummy(self, *args, **kwargs):
return True
import farine.rpc
class Client(object):
@farine.rpc.client('myotherservice')
def dummy(self, rpc):
"""
:param rpc: The RPC client.
:type rpc: farine.rpc.client.Client
"""
result = rpc.dummy()
RPC Stream
Example:
import farine.rpc
class Server(object):
@farine.rpc.method()
def dummy(self, *args, **kwargs):
yield 'a'
yield 'b'
import farine.rpc
class Client(object):
@farine.rpc.client('myotherservice')
def dummy(self, rpc):
"""
:param rpc: The RPC client.
:type rpc: farine.rpc.client.Client
"""
for result in rpc.dummy(__stream__=True):
print result
HTTP Stream
import farine.stream
class Client(object):
@farine.stream.http()
def listen_event(self, data):
"""
:param data: The event sent.
:type data: dict
"""
return True
Execute method
import farine.execute
class Client(object):
@farine.execute.method()
def my_own_stuff(self):
"""
Your own code.
"""
Database
Example
models.py:
from farine.connectors.sql import *
class User(Model):
name = CharField()
service.py:
import farine.amqp
from models import User
class Client(object):
@farine.amqp.consume(exchange='exchange', routing_key='routing_key')
def select(self, body, message):
return User.select().where(User.id==1)
Overview
Example
import farine.rpc
import farine.stream
class Client(object):
@farine.stream.http()
def get(self, data):
return self.send(data)
@farine.rpc.client('myotherservice')
def send(self, rpc, data):
return rpc.process(data)
Configuration
By default the configuration file is located in /etc/farine.ini. You can override this path using the environment variable FARINE_INI.
Example
[DEFAULT] amqp_uri = amqp://baguette:baguette@127.0.0.1:5672/baguette [consume] enabled = true
Database
If you use a database connection, you have to add in the [DEFAULT] section the db parameters:
[DEFAULT] db_connector = postgres (required) db_name = name (required) db_user = user (required) db_host = host (required) db_password = password (required) db_port = port (optional) db_max_conn = max_connections (optional) db_stale_timeout = stale timeout (optional) db_timeout = timeout (optional)
Launch
To launch a service, just run:
farine --start=mymodule
It will try to import mymodule.service and launch it.
Metadata
Release files for baguette-messaging 0.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| baguette-messaging-0.19.tar.gz | 18.9 kB | Without provenance | Details |
Release files / baguette-messaging-0.19.tar.gz
| Download URL | baguette-messaging-0.19.tar.gz |
|---|---|
| Size | 18.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6f1a7022f2d5f974b54014625df2a7d2df34a75c0d3202f3f715a8e64411b74
|
|
BLAKE2b-256 checksum How to use checksums |
60bdc947d994b5ef0022c6ccf04764b5a43cb121080f3795809ed3ed06bc9be7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for baguette-messaging 0.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.