-
Notifications
You must be signed in to change notification settings - Fork 76
ari 3.0 Event Filtering
Sheena Artrip edited this page Sep 26, 2016
·
1 revision
We've discussed event filtering via these single method interfaces:
type ChannelEvent interface {
GetChannelID() string
}
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.
- Should we just use one channel on GetChannelID()? so we only filter on one specific channel field?
- Should we refactor our filtering mechanism?
// 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.