Skip to main content

Provides abstract classes for messages publication in async queues

Project description

Classic Messaging

This package provides abstract classes for message queues.

Usage:

from classic.components import component
from classic.messaging import Message, Publisher


@component
class SomeService:
    publisher: Publisher

    def do_some_work(self):
        message = Message('target', 'Some very useful info')
        self.publisher.publish(message)

Publisher have inner buffer. Messages can be planned for publishing, and will be published later

Usage with deferred publishing:

from classic.components import component
from classic.messaging import Message, Publisher


@component
class SomeService:
    publisher: Publisher

    def create_message(self):
        message = Message('target', 'Some very useful info')
        self.publisher.plan(message)

    def do_some_work(self):
        try:
            self.create_message()
        except Exception:
            self.publisher.reset()
            raise 
        else:
            self.publisher.flush()

Usage with join_points:

from classic.components import component
from classic.messaging import Message, Publisher
from classic.aspects import join_poin


@component
class SomeService:
    publisher: Publisher
    
    @join_poin
    def do_some_work(self):
        message = Message('target', 'Some very useful info')
        self.publisher.plan(message)

        
class RealPublisher(Publisher):
    
    def publish(self, message):
        print(message)


publisher = RealPublisher()

SomeService.do_some_work.join(publisher)

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

classic-messaging-0.0.2.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

classic_messaging-0.0.2-py3-none-any.whl (4.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