From 3d6d1b6b0d2d2f0d48408df1dc249baaa505b884 Mon Sep 17 00:00:00 2001 From: Gleb Beloded Date: Thu, 24 Oct 2024 17:32:44 +0200 Subject: [PATCH 1/2] add context option --- options.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/options.go b/options.go index 9014cd2..b55dcf7 100644 --- a/options.go +++ b/options.go @@ -1,6 +1,7 @@ package gosundheit import ( + "context" "time" ) @@ -34,6 +35,12 @@ func WithHealthListeners(listener ...HealthListener) HealthOption { }) } +func WithContext(ctx context.Context) HealthOption { + return healthOptionFunc(func(h *health) { + h.ctx = ctx + }) +} + // WithDefaults sets all the Health object settings. It's not required to use this as no options is always default // This is a simple placeholder for any future defaults func WithDefaults() HealthOption { From a3aa3462a6ee5974d9b4cb94bebe74b36cbaa441 Mon Sep 17 00:00:00 2001 From: Gleb Beloded Date: Tue, 29 Oct 2024 17:51:01 +0100 Subject: [PATCH 2/2] add go doc comment --- options.go | 1 + 1 file changed, 1 insertion(+) diff --git a/options.go b/options.go index b55dcf7..fbfa5c3 100644 --- a/options.go +++ b/options.go @@ -35,6 +35,7 @@ func WithHealthListeners(listener ...HealthListener) HealthOption { }) } +// WithContext allows providing non-default context to be used inside health checks func WithContext(ctx context.Context) HealthOption { return healthOptionFunc(func(h *health) { h.ctx = ctx