package settings import "context" type reloadedContextKey struct{} // MarkReloadedInContext marks that a given Settings instance has been refreshed in this context flow. func MarkReloadedInContext(ctx context.Context, cfg *Settings) context.Context { if ctx == nil { ctx = context.Background() } if cfg == nil { return ctx } return context.WithValue(ctx, reloadedContextKey{}, cfg) } // IsReloadedInContext reports whether this context flow already refreshed the provided Settings. func IsReloadedInContext(ctx context.Context, cfg *Settings) bool { if ctx == nil || cfg == nil { return false } marked, ok := ctx.Value(reloadedContextKey{}).(*Settings) if !ok || marked == nil { return false } return marked == cfg }