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

ari 3.0 - event filtering #50

Closed
sheenobu opened this issue Sep 23, 2016 · 2 comments
Closed

ari 3.0 - event filtering #50

sheenobu opened this issue Sep 23, 2016 · 2 comments
Assignees
Labels

Comments

@sheenobu
Copy link
Contributor

sheenobu commented Sep 23, 2016

We've discussed event filtering via these single method interfaces:

type ChannelEvent interface {
   GetChannelID() string
}

Issue

Certain events have multiple channel IDs, for example BridgeBlindTransfer:

type BridgeBlindTransfer struct {
   Bridge BridgeData
   Channel ChannelData
   ReplaceChannel ChannelData
   Transferee ChannelData
}

There is only one Bridge but multiple Channels.

  1. Should we just use one channel on GetChannelID()? so we only filter on one specific channel field?
  2. Should we refactor our filtering mechanism?

Refactoring

// Matcher is an interface Handles can implement to provide event filtering
type Matcher interface {
   Matches(evt ari.Event) bool
}

// ChannelEvent allows arbitrary events to give a Matcher a series of Channel IDs to operate on.
type ChannelEvent interface {
   GetChannelIDs() []string // multiple ID support
}

// Example code:

var channelHandle ChannelHandle
evt <- sub.Events()
if !channelHandle.Matches(evt) {
   //ignore event 
} else {
  // process event
}

Writing this up.... I think I'll go with the refactoring anyway. That will move the event filtering logic from the individual Subscribe implementations in client/native and client/nc into the main ari package and each client only needs to call handle.Matches(evt) before dispatching to the subscription.

@sheenobu
Copy link
Contributor Author

This is done. Keeping open for documentation

@sheenobu sheenobu modified the milestone: ARI 3.0 Sep 26, 2016
@sheenobu
Copy link
Contributor Author

Moved to wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants