Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ The primary base classes for building message consumers.

::: rejected.consumer.Consumer

::: rejected.consumer.PublishingConsumer

::: rejected.consumer.SmartConsumer

::: rejected.consumer.SmartPublishingConsumer

## Exceptions

::: rejected.consumer.ConsumerException
Expand Down
5 changes: 0 additions & 5 deletions docs/api_consumer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,3 @@ Consumer
:members:
:inherited-members:
:exclude-members: execute, log_exception, on_confirmation, require_setting, set_channel

.. autoclass:: rejected.consumer.PublishingConsumer
:members:
:inherited-members:
:exclude-members: execute, log_exception, on_confirmation, require_setting, set_channel
12 changes: 0 additions & 12 deletions docs/api_smart_consumer.rst

This file was deleted.

23 changes: 10 additions & 13 deletions docs/consumer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@

Consumer API
============
The :py:class:`Consumer <rejected.consumer.Consumer>` and
:py:class:`SmartConsumer <rejected.consumer.SmartConsumer>` classes to extend
The :py:class:`Consumer <rejected.consumer.Consumer>` class to extend
for consumer applications.

While the :py:class:`Consumer <rejected.consumer.Consumer>` class provides all
the structure required for implementing a rejected consumer,
the :py:class:`SmartConsumer <rejected.consumer.SmartConsumer>` adds
functionality designed to make writing consumers even easier. When messages
are received by consumers extending :py:class:`SmartConsumer <rejected.consumer.SmartConsumer>`,
if the message's ``content_type`` property contains one of the supported mime-types,
the message body will automatically be deserialized, making the deserialized
message body available via the ``body`` attribute. Additionally, should one of
the supported ``content_encoding`` types (``gzip`` or ``bzip2``) be specified in the
message's property, it will automatically be decoded.
The :py:class:`Consumer <rejected.consumer.Consumer>` class provides all
the structure required for implementing a rejected consumer, including
automatic deserialization of message bodies based on the message's
``content_type`` property. When messages are received, if the message's
``content_type`` property contains one of the supported mime-types, the message
body will automatically be deserialized, making the deserialized message body
available via the ``body`` attribute. Additionally, should one of the supported
``content_encoding`` types (``gzip`` or ``bzip2``) be specified in the message's
property, it will automatically be decoded.

Message Type Validation
-----------------------
Expand Down Expand Up @@ -51,7 +49,6 @@ Consumer Classes
:maxdepth: 1

api_consumer
api_smart_consumer

Exceptions
----------
Expand Down
8 changes: 4 additions & 4 deletions docs/consumer_howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ __version__ = '1.0.0'
LOGGER = logging.getLogger(__name__)


class ExampleConsumer(consumer.PublishingConsumer):
class ExampleConsumer(consumer.Consumer):

def process(self):
LOGGER.info(self.body)
self.publish('new-exchange', 'routing-key', {}, self.body)
self.publish_message('new-exchange', 'routing-key', {}, self.body)
```

Note that the previous example extends `rejected.consumer.PublishingConsumer`
instead of `rejected.consumer.Consumer`.
Note that `consumer.Consumer` supports publishing directly — there is no need
to extend a separate `PublishingConsumer` class.
2 changes: 1 addition & 1 deletion examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
__version__ = '1.0.0'


class ExampleConsumer(consumer.SmartConsumer):
class ExampleConsumer(consumer.Consumer):
def process(self):
self.logger.info('Message: %r', self.body)
action = random.randint(0, 100)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies = [
]

[project.optional-dependencies]
avro = ["fastavro>=1.7", "requests>=2.28"]
html = ["beautifulsoup4"]
msgpack = ["u-msgpack-python"]
sentry = ["sentry-sdk>=2,<3"]
Expand Down
8 changes: 2 additions & 6 deletions rejected/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
logging.getLogger(__name__).addHandler(logging.NullHandler())

from rejected.consumer import ( # noqa: E402
AVRO_DATUM_MIME_TYPE,
Consumer,
ConsumerException,
MessageException,
ProcessingException,
PublishingConsumer,
SmartConsumer,
SmartPublishingConsumer,
)
Comment thread
gmr marked this conversation as resolved.

__author__ = 'Gavin M. Roy <gavinmroy@gmail.com>'
Expand All @@ -27,13 +25,11 @@
__version__ = 'unknown'

__all__ = [
'AVRO_DATUM_MIME_TYPE',
'Consumer',
'ConsumerException',
'MessageException',
'ProcessingException',
'PublishingConsumer',
'SmartConsumer',
'SmartPublishingConsumer',
'__author__',
'__since__',
'__version__',
Expand Down
1 change: 1 addition & 0 deletions rejected/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class ConsumerConfig(pydantic.BaseModel):
qos_prefetch: int = 1
max_errors: int = 5
error_exchange: str | None = None
schema_uri_format: str | None = None
sentry_dsn: str | None = None
drop_exchange: str | None = None
drop_invalid_messages: bool | None = None
Expand Down
Loading
Loading