Skip to main content

No project description provided

Project description

FastMessage

stars license last commit tests Documentation Status pypi version python compatibility downloads

FastMessage is an easy framework to create PipelineHandlers for MessageFlux

You can find the full documentation here

Requirements

Python 3.7+

Installation

$ pip install fastmessage

Examples

from fastmessage import FastMessage, OtherMethodOutput
from messageflux.iodevices.rabbitmq import RabbitMQInputDeviceManager, RabbitMQOutputDeviceManager

fm = FastMessage()


@fm.map()
def hello(name: str, birthYear: int):
    age = 2023 - birthYear
    print(f'Hello {name}. your age is {age}')
    return OtherMethodOutput(next_year, age=age)  # this sends its output to 'next_year' method


@fm.map()
def next_year(age: int):
    print(f'next year you will be {age + 1}')


if __name__ == "__main__":
    input_device_manager = RabbitMQInputDeviceManager(hosts='my.rabbit.host',
                                                      user='username',
                                                      password='password')

    output_device_manager = RabbitMQOutputDeviceManager(hosts='my.rabbit.host',
                                                        user='username',
                                                        password='password')

    service = fm.create_service(input_device_manager=input_device_manager,
                                output_device_manager=output_device_manager)
    service.start()  # this runs the PipelineService and blocks

This example shows two methods: hello and next_year, each listening on its own queue (with the same name)

the __main__ creates an input and output device managers (RabbitMQ in this case), and starts the service with these devices.

every message that is sent to the hello queue should have the following format:

{
  "name": "john",
  "birthYear": 1999
}

in that case the process will print (in 2023...):

Hello john. your age is 24
next year you will be 25

Project details


Download files

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

Source Distribution

fastmessage-0.2.1.tar.gz (10.9 kB view hashes)

Uploaded Source

Built Distribution

fastmessage-0.2.1-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page