Queue the events in the event bus before the bus is started. #117

Open
wants to merge 1 commit into
from

Projects

None yet

2 participants

@brasmusson
Contributor
brasmusson commented Nov 27, 2016 edited

Summary

To avoid that listeners miss events broadcast before the got a change to register themselves with the event bus, the bus needs to queue events until an explicit start message is received.

Details

Before the EventBus#start method has been called, the EventBus will queue broadcast events, and then pass them on to the handlers when EventBus#start is called.
After the EventBus#start method has been called, the EventBus immediately pass on broadcast event to the handlers.

Motivation and Context

Is needed for fix of cucumber/cucumber-ruby#1041, see cucumber/cucumber-ruby#1059.

How Has This Been Tested?

Rspec specs have been updated to cover the changed functionality.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I've added tests for my code
@brasmusson brasmusson Queue the events in the event bus before the bus is started.
To avoid that listeners miss events broadcast before the got a change
to register themselves with the event bus, the bus needs to queue
events until an exeplicit start message is received.
52da142
@brasmusson brasmusson referenced this pull request in cucumber/cucumber-ruby Nov 27, 2016
Open

Start the event bus after all listeners are registered #1059

2 of 2 tasks complete
@mattwynne
Member

@brasmusson I finally had a chance to get my head around this change. I had a think about it, and I wonder if it might be simpler, rather than having an explicit start method, to just queue all events, and automatically replay any queued events to new subscribers as they register. WDYT?

I had a play with that idea here: https://github.com/cucumber/cucumber-ruby-core/compare/event-bus-queue-alternative

Would it work?

@brasmusson
Contributor

@mattwynne Yes the event-bus-queue-alternative should work - with it I have managed to verify that cucumber/cucumber-ruby#1041 would disappear with it. What I still would change in Cucumber-Ruby from cucumber/cucumber-ruby#1059 is most of the changes in runtime.rb - reverting the changes from cucumber/cucumber-ruby#977 in runtime.rb to be exact - delaying the loading of step definitions until the formatters are created which was introduced there - does not make any sense any more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment