add Stop function to module

This commit is contained in:
Joel Wetzell
2026-02-07 09:53:38 -06:00
parent 8f5091cf9b
commit 33ecc94097
19 changed files with 156 additions and 18 deletions

View File

@@ -17,6 +17,7 @@ type HTTPClient struct {
client *http.Client
router route.RouteIO
logger *slog.Logger
cancel context.CancelFunc
}
func init() {
@@ -44,7 +45,9 @@ func (hc *HTTPClient) Run(ctx context.Context) error {
return errors.New("http.client unable to get router from context")
}
hc.router = router
hc.ctx = ctx
moduleContext, cancel := context.WithCancel(ctx)
hc.ctx = moduleContext
hc.cancel = cancel
hc.client = &http.Client{
Timeout: 10 * time.Second,
@@ -79,3 +82,7 @@ func (hc *HTTPClient) Output(ctx context.Context, payload any) error {
return nil
}
func (hc *HTTPClient) Stop() {
hc.cancel()
}