mirror of
https://github.com/eosswedenorg/antelope-api-healthcheck
synced 2026-08-26 20:48:13 +02:00
internal/api/interface.go: make Call() accept a context as parameter.
This commit is contained in:
parent
b815bcee44
commit
dbf59d1305
10 changed files with 47 additions and 30 deletions
|
|
@ -108,8 +108,12 @@ func (s *Server) OnTraffic(c gnet.Conn) gnet.Action {
|
|||
// gnet library does not like blocking calls.
|
||||
// as we do a blocking http call here, we need to wrap it in a goroutine.
|
||||
go func() {
|
||||
// Make a context with 30 sec timeout per default. Should be "enough" for most cases.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
|
||||
defer cancel()
|
||||
|
||||
t := time.Now()
|
||||
status, msg := healthCheckApi.Call()
|
||||
status, msg := healthCheckApi.Call(ctx)
|
||||
req_time := time.Since(t)
|
||||
|
||||
params := api.LogParams{}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue