Enable event persistence in webhook (#7614)

This commit is contained in:
Praveen raj Mani
2019-07-05 15:21:41 +05:30
committed by Nitish Tiwari
parent 0ebbd3caef
commit bb871a7c31
8 changed files with 132 additions and 15 deletions

View File

@@ -19,7 +19,10 @@ package target
import (
"errors"
"fmt"
"net"
"os"
"strings"
"syscall"
"time"
"github.com/minio/minio/pkg/event"
@@ -76,6 +79,18 @@ func replayEvents(store Store, doneCh <-chan struct{}) <-chan string {
return eventKeyCh
}
// isConnResetErr - Checks for connection reset errors.
func isConnResetErr(err error) bool {
if opErr, ok := err.(*net.OpError); ok {
if syscallErr, ok := opErr.Err.(*os.SyscallError); ok {
if syscallErr.Err == syscall.ECONNRESET {
return true
}
}
}
return false
}
// sendEvents - Reads events from the store and re-plays.
func sendEvents(target event.Target, eventKeyCh <-chan string, doneCh <-chan struct{}) {
retryTimer := time.NewTimer(retryInterval)
@@ -88,7 +103,7 @@ func sendEvents(target event.Target, eventKeyCh <-chan string, doneCh <-chan str
break
}
if err != errNotConnected {
if err != errNotConnected && !isConnResetErr(err) {
panic(fmt.Errorf("target.Send() failed with '%v'", err))
}