Enhance the event store interface to support channeling (#7343)

- Avoids code duplication across the other targets. By having a
  centralized function call.

- Reduce the room for race.
This commit is contained in:
Praveen raj Mani
2019-04-10 18:16:01 +05:30
committed by Nitish Tiwari
parent ddb0d646aa
commit 47ca411163
20 changed files with 377 additions and 144 deletions

View File

@@ -24,7 +24,8 @@ import (
// Target - event target interface
type Target interface {
ID() TargetID
Send(Event) error
Save(Event) error
Send(string) error
Close() error
}
@@ -130,7 +131,7 @@ func (list *TargetList) Send(event Event, targetIDs ...TargetID) <-chan TargetID
wg.Add(1)
go func(id TargetID, target Target) {
defer wg.Done()
if err := target.Send(event); err != nil {
if err := target.Save(event); err != nil {
errCh <- TargetIDErr{
ID: id,
Err: err,