Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add `Channel#await` method #5

Closed
vladfaust opened this issue Mar 14, 2019 · 2 comments

Comments

Projects
1 participant
@vladfaust
Copy link
Member

commented Mar 14, 2019

Should block and wait for the first event occurrence, returning the block execution result:

id = channel.await(JobCreated, request_uuid: job.uuid) do |event|
  return event.instance_id
end

pp id # => `event.instance_id` value

Proposed method signature:

def await(event : T.class, event_id : String = nil, **filter : **U) forall T, U
end

@vladfaust vladfaust self-assigned this Mar 14, 2019

@vladfaust vladfaust added this to To do in Kanban via automation Mar 14, 2019

@vladfaust vladfaust added this to the next patch milestone Mar 14, 2019

@vladfaust

This comment has been minimized.

Copy link
Member Author

commented Mar 14, 2019

This should also work with select:

select
when event = channel.await(EventA)
when event = channel.await(EventB)
end
@vladfaust

This comment has been minimized.

Copy link
Member Author

commented Mar 16, 2019

Should also support timeout : Time::Span? = nil argument and raise Onyx::EDA::AwaitTimeout error.

@vladfaust vladfaust moved this from To do to In progress in Kanban Mar 26, 2019

vladfaust added a commit that referenced this issue Mar 26, 2019

vladfaust added a commit that referenced this issue Mar 29, 2019

overhaul
BREAKING CHANGE: `Channel` is an abstract class now, use `Channel::Memory` and `Channel::Redis`.

BREAKING CHANGE: No need to pass a subscribing object to `Channel#subscribe` anymore. It returns `Channel::Subscription` instance which has `#unsubscribe` method.

BREAKING CHANGE: `Channel#subscribe` accepts `filter` or `consumer_id` arguments. The former enables event filtering and the latter enables consuming instead of subscribing. Closes #3 and also closes #4.

BREAKING CHANGE: `Channel#emit` returns the events themselves.

Added `Channel#await` method, which closes #5.

Events have an `#event_id` getter with random UUID by default, which closes #6.

Added `Subscriber` and `Consumer` modules.

Fixed requiring logic of events when using `Channel::Redis`, the requiring order should not matter anymore.

Also added triggering dependant Travis CI builds.

@vladfaust vladfaust modified the milestones: next patch, next minor Apr 2, 2019

@vladfaust vladfaust closed this in bbfca29 Apr 16, 2019

Kanban automation moved this from In progress to Done Apr 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.