Should we just use one channel on GetChannelID()? so we only filter on one specific channel field?
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.
We've discussed event filtering via these single method interfaces:
Issue
Certain events have multiple channel IDs, for example
BridgeBlindTransfer
:There is only one Bridge but multiple Channels.
Refactoring
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.