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

@@ -64,8 +64,12 @@ func (target WebhookTarget) ID() event.TargetID {
return target.id
}
// Send - sends event to Webhook.
func (target *WebhookTarget) Send(eventData event.Event) error {
// Save - Sends event directly without persisting.
func (target *WebhookTarget) Save(eventData event.Event) error {
return target.send(eventData)
}
func (target *WebhookTarget) send(eventData event.Event) error {
objectName, err := url.QueryUnescape(eventData.S3.Object.Key)
if err != nil {
return err
@@ -100,6 +104,11 @@ func (target *WebhookTarget) Send(eventData event.Event) error {
return nil
}
// Send - interface compatible method does no-op.
func (target *WebhookTarget) Send(eventKey string) error {
return nil
}
// Close - does nothing and available for interface compatibility.
func (target *WebhookTarget) Close() error {
return nil