Skip to content

Releases: kalaspuff/tomodachi

0.19.0

23 Oct 15:26
d15bf09
Compare
Choose a tag to compare

Breaking API changes / updates to default behaviour

  • @tomodachi.aws_sns_sqs and @tomodachi.amqp decorators has changed the default value of the competing keyword-argument to True. 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 the auto (or default) value will use Python's builtin asyncio event loop. Note that this is a change in behaviour and the default event loop will now be asyncio instead of uvloop.
  • 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 the options.http.keepalive_timeout config value.
  • The @tomodachi.aws_sns_sqs decorator can now specify a filter_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". If filter_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 the filter_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 the message_attributes keyword argument. Values should be specified as a simple dict 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 and options.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. The tomodachi.get_execution_context() function returns a dict 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 the queue_url, receipt_handle and message_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 to message_envelope and the two example implementations JsonBase and ProtobufBase has been moved from tomodachi.protocol to tomodachi.envelope. The previous imports and service attribute is deprecated, but can still be used. Likewise the optional message_protocol keyword argument passed to @tomodachi.aws_sns_sqs, @tomodachi.amqp, aws_sns_sqs_publish, amqp_publish is renamed to message_envelope.
  • The service class decorator @tomodachi.service is now considered deprecated and the service classes should inherit from the tomodachi.Service class instead. This also works better with type-hinting, which currently cannot handle decorators that modify a class.

Documentation update

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 using aiohttp.
  • 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 and topic_prefix to aws_sns_sqs_publish is now keyword only.
  • The arguments to specify message_envelope and routing_key_prefix to amqp_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 with pyproject.toml with a Poetry section together with the poetry.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

15 Sep 15:24
33ecb98
Compare
Choose a tag to compare
  • Changed the order of when to execute the service's own _stop_service() function, to always run after active HTTP requests has finished executing, as well as awaiting ongoing AMQP before finally running the user defined function.

0.17.1

16 Jun 08:32
d033d68
Compare
Choose a tag to compare
  • Updated generated proto class using protoc 3.12.2 for messages using proto envelope, which should solve some deprecation warnings.

0.17.0

16 Jun 02:35
a26ef1d
Compare
Choose a tag to compare
  • 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

25 Feb 09:57
39b368a
Compare
Choose a tag to compare
  • Removes the dependency on ujson.

0.16.5

12 Feb 14:44
6b2d5f6
Compare
Choose a tag to compare
  • Bugfix for context reference mismatch when using custom invocation decorators which could cause the provided context variable to not include the correct information.

0.16.4

28 Aug 20:09
7316f37
Compare
Choose a tag to compare
  • Fix for the the race condition causing delete_message to raise an exception, when draining the SQS receive messages call, while stopping the service.

0.16.3

22 Aug 23:02
bfdc8cb
Compare
Choose a tag to compare
  • 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 specifying request 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 allow aioamqp==0.13.x.

0.16.2

27 Mar 09:57
Compare
Choose a tag to compare
  • Added keyword arguments for overriding the topic_prefix and routing_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.

0.16.1

21 Mar 17:03
Compare
Choose a tag to compare
  • Bug fix for websocket handler function's signature inspection in middlewares, which caused the function signature to return a non-wrapped internal function.