class CoroutineContextStorage implements ContextStorageInterface, ExecutionContextAwareInterface

Store OpenTelemetry context in Hypervel's coroutine-local context.

Constants

CONTEXT_KEY

Properties

protected ContextState $mainState
protected ContextState $fallbackState
protected array<int|ContextState> $fallbackStates

Methods

__construct(ContextInterface $baseContext)

Create a coroutine context storage.

void
fork(int|string $id)

Snapshot the current context for another execution unit.

void
switch(int|string $id)

Switch to a registered fallback execution unit.

void
destroy(int|string $id)

Forget a registered fallback execution unit.

ContextStorageScopeInterface|null
scope()

Return the active scope.

ContextInterface
current()

Return the active context.

ContextStorageScopeInterface
attach(ContextInterface $context)

Attach a context to the current execution unit.

bool
isActive(ContextState $state)

Determine whether a scope's owning execution unit is active.

state()

Return or create the current execution unit's state.

existingState()

Return the current state without creating one.

Details

at line 32
__construct(ContextInterface $baseContext)

Create a coroutine context storage.

Parameters

ContextInterface $baseContext

at line 40
void fork(int|string $id)

Snapshot the current context for another execution unit.

Parameters

int|string $id

Return Value

void

at line 49
void switch(int|string $id)

Switch to a registered fallback execution unit.

Parameters

int|string $id

Return Value

void

at line 64
void destroy(int|string $id)

Forget a registered fallback execution unit.

Parameters

int|string $id

Return Value

void

at line 73
ContextStorageScopeInterface|null scope()

Return the active scope.

Return Value

ContextStorageScopeInterface|null

at line 82
ContextInterface current()

Return the active context.

Return Value

ContextInterface

at line 91
ContextStorageScopeInterface attach(ContextInterface $context)

Attach a context to the current execution unit.

Parameters

ContextInterface $context

Return Value

ContextStorageScopeInterface

at line 106
bool isActive(ContextState $state)

internal  
 

Determine whether a scope's owning execution unit is active.

Parameters

ContextState $state

Return Value

bool

at line 114
protected ContextState state()

Return or create the current execution unit's state.

Return Value

ContextState

at line 133
protected ContextState|null existingState()

Return the current state without creating one.

Return Value

ContextState|null