wip: output, pipe
This commit is contained in:
@ -20,3 +20,19 @@ func Timeout(seconds ...int) (ctx context.Context) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func TimeoutCtx(parent context.Context, seconds ...int) (ctx context.Context) {
|
||||
var (
|
||||
duration time.Duration
|
||||
)
|
||||
|
||||
if len(seconds) > 0 && seconds[0] > 0 {
|
||||
duration = time.Duration(seconds[0]) * time.Second
|
||||
} else {
|
||||
duration = time.Duration(30) * time.Second
|
||||
}
|
||||
|
||||
ctx, _ = context.WithTimeout(parent, duration)
|
||||
|
||||
return
|
||||
}
|
||||
|
14
internal/util/es7.go
Normal file
14
internal/util/es7.go
Normal file
@ -0,0 +1,14 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/elastic/go-elasticsearch/v7/esapi"
|
||||
)
|
||||
|
||||
func CheckES7Response(result *esapi.Response) error {
|
||||
if result.StatusCode != 200 {
|
||||
return fmt.Errorf("status=%s msg=%s", result.StatusCode, result.String())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user