Releases: kalaspuff/tomodachi
Releases · kalaspuff/tomodachi
0.19.0
Breaking API changes / updates to default behaviour
@tomodachi.aws_sns_sqs
and@tomodachi.amqp
decorators has changed the default value of thecompeting
keyword-argument toTrue
. Note that this is a change in default behaviour and may be a breaking change if "non-competing" services were used. This change was triggered in an attempt to make the API more clear and use more common default values. It's rare that a non-shared queue would be used for service replicas of the same type in a distributed architecture.- The event loop that the process will execute on can now be specified on startup using
--loop [auto|asyncio|uvloop]
, currently theauto
(ordefault
) value will use Python's builtinasyncio
event loop. Note that this is a change in behaviour and the default event loop will now beasyncio
instead ofuvloop
. - Dropped support for Python 3.6.
Features
- HTTP server functionality, which is based on
aiohttp
, can now be configured to allow keep-alive connections by specifying theoptions.http.keepalive_timeout
config value. - The
@tomodachi.aws_sns_sqs
decorator can now specify afilter_policy
which will be applied on the SNS subscription (for the specified topic and queue) as the"FilterPolicy
attribute. This will apply a filter on SNS messages using the chosen "message attributes" and/or their values specified in the filter. Example: A filter policy value of{"event": ["order_paid"], "currency": ["EUR", "USD"]}
would set up the SNS subscription to receive messages on the topic only where the message attribute"event"
is"order_paid"
and the"currency"
value is either"EUR"
or"USD"
. Iffilter_policy
is not specified as an argument, the queue will receive messages on the topic as per already specified if using an existing subscription, or receive all messages on the topic if a new subscription is set up (default). Changing thefilter_policy
on an existing subscription may take several minutes to propagate. Read more about the filter policy format on AWS, since it doesn't follow the same pattern as specifying message attributes. https://docs.aws.amazon.com/sns/latest/dg/sns-subscription-filter-policies.html - Related to the above mentioned filter policy, the
aws_sns_sqs_publish
function has also been updated with the possibility to specify said "message attributes" using themessage_attributes
keyword argument. Values should be specified as a simpledict
with keys and values. Example:{"event": "order_paid", "paid_amount": 100, "currency": "EUR"}
. - Added SSL and virtualhost settings to AMQP transport, as well as additional configuration options which can be passed via
options.amqp.virtualhost
,options.amqp.ssl
andoptions.amqp.heartbeat
. (github: xdmiodz) - Added
tomodachi.get_execution_context()
that holds metadata about the service execution that can be used for debugging purposes or be sent to application monitoring platforms such as Sentry or to be included in custom log output for log search indexing. Thetomodachi.get_execution_context()
function returns adict
with installed package versions of some key dependencies, function call counters of different types, etc.
Bug fixes
- Fixes a bug that could cause a termination signal to stop the service in the middle of processing a message received via AWS SQS. The service will now await currently executing tasks before finally shutting down.
- Service termination for HTTP based services will now correctly await started tasks from clients that has disconnected before receiving the response.
- Functions decorated with
@tomodachi.aws_sns_sqs
will now be called with thequeue_url
,receipt_handle
andmessage_attributes
keyword arguments if specified in the function signature. These can be used to update the visibility timeouts, among other things.
Deprecation notice
- The
message_protocol
value that can be specified on service classes has been renamed tomessage_envelope
and the two example implementationsJsonBase
andProtobufBase
has been moved fromtomodachi.protocol
totomodachi.envelope
. The previous imports and service attribute is deprecated, but can still be used. Likewise the optionalmessage_protocol
keyword argument passed to@tomodachi.aws_sns_sqs
,@tomodachi.amqp
,aws_sns_sqs_publish
,amqp_publish
is renamed tomessage_envelope
. - The service class decorator
@tomodachi.service
is now considered deprecated and the service classes should inherit from thetomodachi.Service
class instead. This also works better with type-hinting, which currently cannot handle decorators that modify a class.
Documentation update
- Overall updated documentation and improved examples around running services within Docker.
- https://tomodachi.dev/docs
Minor changes
- Updated identifiers for support of Python 3.9.
- More verbose output when waiting for active tasks during termination.
- Updated startup output with additional information about the running process, including versions, etc.
- Added
aiodns
as an optional installation, as it's recommended for running DNS resolution on the event loop when usingaiohttp
. uvloop
is now an optional installation.- The argument to specify
message_envelope
on the@tomodachi.aws_sns_sqs
and@tomodachi.amqp
decorators is now keyword only. - The arguments to specify
message_envelope
andtopic_prefix
toaws_sns_sqs_publish
is now keyword only. - The arguments to specify
message_envelope
androuting_key_prefix
toamqp_publish
is now keyword only. - The
name
attribute is no longer required on the service classes and if not specified the value will now instead default to"service"
. - Added support for
aiohttp
3.6.x. - Added support for
aiobotocore
1.x.x.
Code style / CI / Contributions
- Refactoring and updates to code formatting, now using Black code style.
requirements.txt
is no more and has been replaced withpyproject.toml
with a Poetry section together with thepoetry.lock
.- Replaced Travis CI with GitHub actions.
- Replaced py-up with GitHub's dependabot, which as of recently also supports Poetry's lock files.
0.18.0
0.17.1
0.17.0
- Proper support for Python 3.8. Now correctly handles
asyncio.exceptions.CancelledError
exceptions that previously sent a lot of unwanted output on service shutdown or restart. - Updated dependencies across the board, utilizing package versions that supports Python 3.8.
- Dropped support for Python 3.5.
- Now gracefully handles shutdown for HTTP based services, by awaiting active requests and giving them time to finish. By default the ongoing HTTP requests will have 30 seconds to complete their work, which can also be configured via
options.http.termination_grace_period_seconds
. - Taking steps into making the codebase following more modern patterns. Additional updates to be followed in a later release.
0.16.6
0.16.5
0.16.4
0.16.3
- It's now possible to get the request object for websocket handlers by adding a third argument to the invoker function.
(self, websocket, request)
or by specifyingrequest
as a keyword argument in the function signature. Using the request object it's now possible to parse browser headers and other data sent when first opening the websocket connction. - Updated packages for automated tests to verify that newer dependencies still works correctly.
- Updated the dependency of
aioamqp
to allowaioamqp==0.13.x
.
0.16.2
- Added keyword arguments for overriding the
topic_prefix
androuting_key_prefix
when publishing messages. Useful by for example intermediaries that needs to publishing messages to external services running on other environments, or services that are otherwise confined to a prefix / environment but needs to contact a core service, i.e. data collection, emails, etc.