mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 04:52:35 +02:00
add timeout to notification context
This commit is contained in:
parent
43fce6e739
commit
8ae9573b07
1 changed files with 5 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
E "github.com/yusing/go-proxy/internal/error"
|
E "github.com/yusing/go-proxy/internal/error"
|
||||||
gphttp "github.com/yusing/go-proxy/internal/net/http"
|
gphttp "github.com/yusing/go-proxy/internal/net/http"
|
||||||
|
@ -40,6 +41,10 @@ func notifyProvider(ctx context.Context, provider Provider, msg *LogMessage) err
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return E.PrependSubject(provider.GetName(), err)
|
return E.PrependSubject(provider.GetName(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(
|
req, err := http.NewRequestWithContext(
|
||||||
ctx,
|
ctx,
|
||||||
http.MethodPost,
|
http.MethodPost,
|
||||||
|
|
Loading…
Add table
Reference in a new issue