Skip to content

Releases: melvinkcx/fastapi-events

v0.6.0

08 Sep 03:26
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.5.1...v0.6.0

v0.5.1

29 Aug 01:37
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.5.0...v0.5.1

v0.5.0

09 Aug 03:07
Compare
Choose a tag to compare

What's Changed

  • Typing/mypy improvements by @smithk86 in #29
  • add optional middleware_id (dispatching events on startup in now possible) by @smithk86 in #28

New Contributors

Full Changelog: v0.4.0...v0.5.0

v0.4.0

29 Apr 08:43
Compare
Choose a tag to compare

What's Changed?

Event Chaining: Dispatching Events Within Handlers

Previously, dispatch() can only be called within a request-response cycle.

With v0.4.0, it is now possible to invoke dispatch() within event handlers. A huge thanks to @ndopj for contributing his idea in #23.

Please refer to this section for more details.

v0.3.0

09 Mar 11:29
Compare
Choose a tag to compare

What's Changed

Event payload validation via Pydantic

Full documentation can be found here

import uuid
from enum import Enum
from datetime import datetime

from pydantic import BaseModel
from fastapi_events.registry.payload_schema import registry as payload_schema


class UserEvents(Enum):
    SIGNED_UP = "USER_SIGNED_UP"
    ACTIVATED = "USER_ACTIVATED"


# Registering your event payload schema
@payload_schema.register(event_name=UserEvents.SIGNED_UP)
class SignUpPayload(BaseModel):
    user_id: uuid.UUID
    created_at: datetime
# Events with payload schema registered
dispatch(UserEvents.SIGNED_UP)  # raises ValidationError, missing payload
dispatch(UserEvents.SIGNED_UP,
         {"user_id": "9e79cdbb-b216-40f7-9a05-20d223dee89a"})  # raises ValidationError, missing `created_at`
dispatch(UserEvents.SIGNED_UP,
         {"user_id": "9e79cdbb-b216-40f7-9a05-20d223dee89a", created_at: datetime.utcnow()})  # OK!

# Events without payload schema -> No validation will be performed
dispatch(UserEvents.ACTIVATED,
         {"user_id": "9e79cdbb-b216-40f7-9a05-20d223dee89a"})  # OK! no validation will be performed

v0.2.2

23 Dec 07:40
7e068fe
Compare
Choose a tag to compare

What's Changed

  • @local_handler.register() can now be chained: (#19, fixes #17)

    @local_handler.register(event_name="foo")
    @local_handler.register(event_name="bar")
    async def handle_foo_bar(event: Event):
         pass
    

v0.2.1

02 Nov 08:15
Compare
Choose a tag to compare

What's Changed

v0.2.0

28 Oct 07:55
Compare
Choose a tag to compare

What's Changed

v0.1.3

25 Oct 05:04
Compare
Choose a tag to compare

What's Changed

  • Fixes #8: Reliably reset context variable after process events (#8, by @emcpow2)
  • Fixes #9: Synchronous local handlers will no longer block the event loop (#11, by @melvinkcx)

v0.1.2

19 Oct 11:47
Compare
Choose a tag to compare

Changelog:

  • Fixed bugs (#5, huge thanks to @emcpow2)