Skip to main content

Romeways

by: CenturyBoys

This project has as goal help developers to not reimplemented default queue consumer behaviour.

Basics

Romeways works with two basic concepts queue handler and queue connector. The queue connector is a queue consumer and can be spawned in a separate process or in async worker. The queue handler is the callback function that will be called for each retrieved message.

Here you can see all implemented consumer:

Queue Type Install using extra description
multiprocessing.Queue memory here
Apache Kafka kafka here

How to install extra packages?

poetry add romeways -E memory
OR
pip install 'romeways[memory]'

Configuration

Queue connector config

The queue connector config is all configurations that you need to be able to retrieve messages from the queue.

Bellow are the romeways.GenericConnectorConfig implementation. This class can be inheritance to allow extra configurations.

Params:

  • connector_name: str For what connector this queue must be delivered
from dataclasses import dataclass


@dataclass(slots=True, frozen=True)
class GenericConnectorConfig:
    """
    connector_name: str Connector name
    """
    connector_name: str

Queue handler config

When you register a queue consumer you are setting configs and a callback handler for each message that this queue receives.

Bellow are the romeways.GenericQueueConfig implementation. This class can be inheritance to allow extra configurations.

Params:

  • connector_name: str For what connector this queue must be delivered
  • frequency: float Time in seconds for retrieve messages from queue
  • max_chunk_size: int Max quantity for messages that one retrieve will get
  • sequential: bool If the handler call must be sequential or in asyncio.gather
from dataclasses import dataclass


@dataclass(slots=True, frozen=True)
class GenericQueueConfig:
    """
    connector_name: str For what connector this queue must be delivered
    frequency: float Time in seconds for retrieve messages from queue
    max_chunk_size: int Max quantity for messages that one retrieve will get
    sequential: bool If the handler call must be sequential or in asyncio.gather
    """
    connector_name: str
    frequency: float
    max_chunk_size: int
    sequential: bool

Resend on error

Romeways allow you to resend the message to the queue if something in your handler do not perform correctly. For that your code need tho raise the romeways.ResendException exception, the message will be resent to the same queue and the romeways.Message.rw_resend_times parameter will be raized

Spawn a process

Romeways can run each connector in a separate process or in async workers for that use the parameter spawn_process to configure that.

Example

For this example we are using the extra package memory

from multiprocessing import Queue

import romeways

# Config the connector
queue = Queue()

# Create a queue config
config_q = romeways.MemoryQueueConfig(
    connector_name="memory-dev1", 
    queue=queue
)

# Register a controller/consumer for the queue name
@romeways.queue_consumer(queue_name="queue.payment.done", config=config_q)
async def controller(message: romeways.Message):
    print(message)

config_p = romeways.MemoryConnectorConfig(connector_name="memory-dev1")

# Register a connector
romeways.connector_register(
    connector=romeways.MemoryQueueConnector, config=config_p, spawn_process=True
)

Download files

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

Source Distribution

rome_ways-0.2.2.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rome_ways-0.2.2-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

Details for the file rome_ways-0.2.2.tar.gz.

File metadata

  • Download URL: rome_ways-0.2.2.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rome_ways-0.2.2.tar.gz
Algorithm Hash digest
SHA256 4bcd2fa4f4998d3c867f7fd57586bad0ac2c0efac5727d9d150eea2ff7f2b976
MD5 bc7062123e9ea6ad82ae4d5366ed0be9
BLAKE2b-256 3f16cad1482aeae82fcaa9457ee5255df739e538e151127f0a6c226825fb2e6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rome_ways-0.2.2.tar.gz:

Publisher: publish.yml on CenturyBoys/romeways

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rome_ways-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: rome_ways-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 27.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for rome_ways-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2b105da4a4750f41906b7c9784c42b09edb521ca911f58abc8b377461835c9ec
MD5 4fa5551adbec43c918aa43f592cc7252
BLAKE2b-256 ccf012308ddbe15ce1eed74eb05c7499dafe1ca73057ca515f2e23ad6ebf5c77

See more details on using hashes here.

Provenance

The following attestation bundles were made for rome_ways-0.2.2-py3-none-any.whl:

Publisher: publish.yml on CenturyBoys/romeways

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page