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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file fastmessage-0.2.1.tar.gz.

File metadata

  • Download URL: fastmessage-0.2.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for fastmessage-0.2.1.tar.gz
Algorithm Hash digest
SHA256 8c34d89be66a635590a60f9a4670db7907dd6b23147b3a616fe67f285d67442b
MD5 65d5f7a1f894c244be7932868d994a1e
BLAKE2b-256 19f4d7328d82505e756404330474366642ce95d31b9755d847745bb280274b46

See more details on using hashes here.

File details

Details for the file fastmessage-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: fastmessage-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for fastmessage-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15428c38bbe747f3045685c2c499c64360f0ea77f40300275df95e8d49a002c9
MD5 74f4ae4214fdd8f238023e17203beebb
BLAKE2b-256 08545442139118d6cc3d18176f8c200e81bbb445faba0c5b19957d387aeb716d

See more details on using hashes here.

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