Skip to content

Commit ded0bec

Browse files
whwalterdskatz
andauthored
istio stop hook defer function (#10)
* istio stop hook defer function * no lint * Update httputils/istio/stophook.go Co-authored-by: David Katz <david.katz@mongodb.com> --------- Co-authored-by: David Katz <david.katz@mongodb.com>
1 parent bda8c60 commit ded0bec

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

httputils/istio/stophook.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package istio
2+
3+
import (
4+
"net/http"
5+
"time"
6+
)
7+
8+
// StopHook takes a timeout in milliseconds and sends a request to istio's stop hook.
9+
// It is intended to be used as a defer function
10+
func StopHook(timeout int) {
11+
c := &http.Client{
12+
Timeout: time.Duration(timeout) * time.Millisecond,
13+
}
14+
r, _ := http.NewRequest("POST", "http://localhost:15000/quitquitquit", nil)
15+
c.Do(r) //nolint
16+
}

0 commit comments

Comments
 (0)