Skip to content

Releases: kalaspuff/tomodachi

0.25.1

11 Aug 18:30
0.25.1
62e2a0d
Compare
Choose a tag to compare
  • Fix for an issue where a wrapped function is used as a handler function, which would then cause the keyword argument provided transport values to rely on the keyword arguments from the wrapped function's signature to be used instead of the keyword arguments from the wrapper function's signature. Described with examples in #1781.

    The bug was found to be present in the 0.25.0 release, which included major refactoring of the keyword argument provided transport values functionality.

0.25.0

22 Jun 15:07
0.25.0
a8dac50
Compare
Choose a tag to compare
  • The middleware execution logic has been improved to handle different argument types and edge cases more smoothly. Enhanced the way arguments are passed to middlewares and handlers, allowing better flexibility.

  • Function handlers, middlewares and envelopes can all now specify additional keyword arguments in their signatures and receive transport centric values.

    Previously a few of these keyword values could be used for function handlers or envelopes, but not within middlewares. With this update these keywords can be used across all kind of handler functions to allow for more flexibility in how to structure apps, logging, tracing, authentication, etc.

  • Resolved an edge case where a service could end up calling SNS.CreateTopic numerous times due to thousands of messages simultanously being published to a topic that were previously unknown to the service. Described in the detail in #1768.

  • The aws_sns_sqs_publish function will now return the SNS message identifier as a str value if it is called with wait=True (default), or instead return an asyncio.Task object if called with wait=False.


Updated documentation on middlewares and function signature keyword arguments:


This is an example of a middleware function for AWS SNS SQS messaging that adds trace spans on receiving messages, with a context extracted from a message attribute holding with a "traceparent" value. The topic name and SNS message identifier is also added as attributes to the trace span.

async def trace_middleware(
    func: Callable[... Awaitable],
    *,
    topic: str,
    message_attributes: dict,
    sns_message_id: str
) -> None:
    ctx: Context | None = None

    if carrier_traceparent := message_attributes.get("telemetry.carrier.traceparent"):
        carrier: dict[str, list[str] | str] = {"traceparent": carrier_traceparent}
        ctx = TraceContextTextMapPropagator().extract(carrier=carrier)

    with tracer.start_as_current_span(f"SNSSQS handler '{func.__name__}'", context=ctx) as span:
        span.set_attribute("messaging.system", "AmazonSQS")
        span.set_attribute("messaging.operation", "process")
        span.set_attribute("messaging.source.name", topic)
        span.set_attribute("messaging.message.id", sns_message_id)

        try:
            # Calls the handler function (or next middleware in the chain)
            await func()
        except BaseException as exc:
            logging.getLogger("exception").exception(exc)
            span.record_exception(exc, escaped=True)
            span.set_status(StatusCode.ERROR, f"{exc.__class__.__name__}: {exc}")
            raise exc

0.24.3

15 Jun 15:01
0.24.3
70e783a
Compare
Choose a tag to compare
  • Fixes an issue in the internal retry logic when using aws_sns_sqs_publish if calls to the AWS API SNS.Publish would intermittently respond with 408 response without any body, which previously would've resulted in a AWSSNSSQSException("Missing MessageId in response") immediately without retries.

    This was previously attempted to be fixed in #1664 (released in 0.23.0), but due to an error it fell through to become an exception with the "Missing MessageId in response" message instead.

    The publish function will now catch exceptions from botocore of type ResponseParserError to which botocore has added that "Further retries may succeed". tomodachi will retry such SNS.Publish calls up to 3 times and if still failing after all retries the library will reraise the original botocore exception.

    It seems that botocore does not automatically retry such errors itself.

  • Similar to the above, the same kind of retries will now also be done during AWS API calls for SQS.DeleteMessage, where the botocore.parser.QueryParser would raise an ResponseParserError exception on 408 responses without body.

0.24.2

13 Jun 09:28
0.24.2
9b8849d
Compare
Choose a tag to compare
  • Fixes typing syntax for compatibility with Python 3.8 and Python 3.9 to solve the incompatibility for Python 3.8 and Python 3.9 introduced in the the 0.24.1 release.
  • Fixes an issue with an AWS SQS queue's message retention period attribute using an incompatible default value for FIFO queues.
  • Support for aiobotocore 2.5.x releases.
  • README.rst fixes to conform with RST format. (github: @navid-agz)

0.24.1

01 Jun 12:57
0.24.1
ddfea07
Compare
Choose a tag to compare
  • Adds max number of messages that the service will consume when using AWS SNS+SQS
    handlers configurable. (github: @navid-agz)
  • Changed default retention period of dead-letter-queues on AWS SNS+SQS.
    (github: @PabloAJomer)

0.24.0

25 Oct 15:26
0.24.0
fffcbde
Compare
Choose a tag to compare
  • cchardet is no longer a direct dependency to tomodachi on Python 3.10 and Python 3.11. If you want to use it, you must install it separately, which may require additional build tools when installing on Python 3.10+.
  • Updates to the internal tomodachi.envelope.ProtobufBase envelope to now also support protobuf Python bindings versioned >=4.0.0, when running with the (new default) PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=upb as upb slightly differs in representation of a Message type in relation to cpp and python implementations.
  • Python 3.11 added to test matrix and trove classifiers to officially claim support.

0.23.0

16 Oct 11:20
c81a873
Compare
Choose a tag to compare
  • Properly handles aiobotocore client using an async contextmanager. Drops support for aiobotocore versions prior 1.3.0, but will now supporting newer versions. (github: @drestrepom)

  • Fixes an issue to now retry calls where AWS SNS intermittently responds with 408 responses without any body, which trips up botocore.parser.QueryParser. (github: @technomunk)

  • Refactored options used for AWS SNS+SQS, HTTP, AMQP and the Watcher functionality. Options set on the service class should now be defined as a tomodachi.Options object, which provides type hints and much nicer path traversal of the class.

    Only the specified typed values for options will now be allowed to be set. Setting a non-defined option will raise an AttributeError exception on service start.

    The previous dict based approach is still supported, but will be removed in a future version.

  • Dropped support for Python 3.7.

0.22.3

09 Aug 09:09
094c4ca
Compare
Choose a tag to compare
  • Support for assigning values to AWS SQS queue attributes value VisibilityTimeout and RedrivePolicy that is used to assign a queue to use a dead-letter queue after a number of failed attempts to consume a message. By default no changes will be done to the existing queue attributes and a change will only be triggered by assigning values to the visibility_timeout or both of dead_letter_queue_name + max_receive_count keyword arguments.
    @tomodachi.aws_sns_sqs(
        topic=None,
        competing=True,
        queue_name=None,
        filter_policy=FILTER_POLICY_DEFAULT,
        visibility_timeout=VISIBILITY_TIMEOUT_DEFAULT,     # affects MessageVisibility
        dead_letter_queue_name=DEAD_LETTER_QUEUE_DEFAULT,  # affects RedrivePolicy
        max_receive_count=MAX_RECEIVE_COUNT_DEFAULT,       # affects RedrivePolicy
        **kwargs,
    )
  • Fixes a bug where SQS messages wouldn't get deleted from the queue if a middleware function catches an exception without reraising it. This is because the delete_message is not called from within routine_func (due to the exception breaking normal control flow), but the message deletion from middleware bubble is also skipped, as no exception is propagated from it. (github: @technomunk)
  • Adds basic support for FIFO queues & topics on AWS SQS queues managed by a tomodachi service decorated function, which can be used where one needs guaranteed ordering of the consumed messages. (github: @kjagiello)
  • Updates to the internal tomodachi.envelope.ProtobufBase envelope to now also support newer versions of protobuf.
  • Added documentation to describe the "magic" functions that hooks into the service lifecycle; _start_service, _started_service, _stopping_service, _stop_service.

0.22.2

07 Apr 09:22
a961c17
Compare
Choose a tag to compare
  • Fixes an issue with live reloading on code changes (development mode) with services utilizing protobuf messages, which in same edge cases could trigger a repeated TypeError("A Message class can only inherit from Message") that would prevent the service from restarting correctly.

0.22.1

14 Mar 17:23
16f3f06
Compare
Choose a tag to compare
  • Added an additional way of gracefully triggering shutdown of a running service, by using the new tomodachi.exit() function, which will initiate the termination processing flow in the same way as signaling SIGINT or SIGTERM. The tomodachi.exit() call can additionally take an optional exit code as an argument to support new ways of catching service operation.
  • The process' exit code can also be altered by changing the value of tomodachi.SERVICE_EXIT_CODE, however using the new tomodachi.exit call with an integer argument will override any previous value set to tomodachi.SERVICE_EXIT_CODE. The default value is set to 0.