MCPcopy Create free account
hub / github.com/codnect/procyon / withCreationState

Function withCreationState

component/state.go:44–56  ·  view source on GitHub ↗

withCreationState adds a new creationState to the given context. If the context already has one, it returns the same context.

(parent context.Context)

Source from the content-addressed store, hash-verified

42// withCreationState adds a new creationState to the given context.
43// If the context already has one, it returns the same context.
44func withCreationState(parent context.Context) context.Context {
45 if parent == nil {
46 parent = context.Background()
47 }
48
49 val := parent.Value(ctxCreationStateContextKey)
50 if val != nil {
51 return parent
52 }
53
54 state := newCreationState()
55 return context.WithValue(parent, ctxCreationStateContextKey, state)
56}
57
58// creationStateFromContext gets the creationState from the context.
59// It assumes the context contains a valid value.

Callers 5

TestWithCreationStateFunction · 0.85
ResolveMethod · 0.85
ResolveTypeMethod · 0.85
ResolveAsMethod · 0.85
ResolveAllMethod · 0.85

Calls 2

newCreationStateFunction · 0.85
ValueMethod · 0.65

Tested by 1

TestWithCreationStateFunction · 0.68