diff --git a/context.go b/context.go deleted file mode 100644 index 1204eaa..0000000 --- a/context.go +++ /dev/null @@ -1,21 +0,0 @@ -package runnable - -import ( - "context" -) - -// ContextValues returns a new context.Context with the values from the parent, without propagating the cancellation. -// Useful when you want to protect an operation that should not be cancelled. -// Often used with context.WithTimeout() or context.WithDeadline(). -func ContextValues(parent context.Context) context.Context { - return valuesCtx{context.Background(), parent} -} - -type valuesCtx struct { - context.Context - parent context.Context -} - -func (c valuesCtx) Value(key interface{}) interface{} { - return c.parent.Value(key) -} diff --git a/context_test.go b/context_test.go deleted file mode 100644 index 54fa0c7..0000000 --- a/context_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package runnable - -import ( - "context" - "testing" - - "github.com/stretchr/testify/require" -) - -type testingContextType string - -func TestContextValues(t *testing.T) { - key := testingContextType("key") - - parent := context.Background() - parent = context.WithValue(parent, key, "value") - parent, cancel := context.WithCancel(parent) - cancel() - - require.Error(t, parent.Err()) - - ctx := ContextValues(parent) - require.Equal(t, "value", ctx.Value(key)) - require.NoError(t, ctx.Err()) -}