Skip to content

Conversation

fnesveda
Copy link
Member

Right now, you can add actor event handlers which accept exactly one argument - event data - even if the event itself does not convey any data (like the migration event). If you try to pass an event handler which accepts no arguments, the event handler will throw when the event happens.

Meaning that this does not work:

def migration_handler():
    print('Migration happened')

Actor.on(ActorEventTypes.MIGRATING, migration_handler)

But this works, because the MIGRATING event never has any data:

def migration_handler(event_data: None):
    assert event_data is None
    print('Migration happened')

Actor.on(ActorEventTypes.MIGRATING, migration_handler)

One user was struggling with this, and it's pretty hard to test, especially for the migrations, so I changed the logic so that the first thing works, and the event handler is passed the event_data argument only if it can accept it.

@fnesveda fnesveda added t-core-services Issues with this label are in the ownership of the core services team. adhoc Ad-hoc unplanned task added during the sprint. labels Mar 20, 2023
@fnesveda fnesveda added this to the 59th sprint - Platform team milestone Mar 20, 2023
@fnesveda fnesveda self-assigned this Mar 20, 2023
@fnesveda fnesveda merged commit d1a17db into master Mar 21, 2023
@fnesveda fnesveda deleted the feature/event-handlers-no-arguments branch March 21, 2023 14:45
@fnesveda fnesveda added the validated Issues that are resolved and their solutions fulfill the acceptance criteria. label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-core-services Issues with this label are in the ownership of the core services team. validated Issues that are resolved and their solutions fulfill the acceptance criteria.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants