reqctx

package
v1.25.0-dev Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RequestDataStoreKey requestDataStoreKeyType

Functions

func NewRequestContext

func NewRequestContext(parentCtx context.Context, profDesc string) (_ context.Context, finished func())

Types

type ContextData

type ContextData map[string]any

func (ContextData) GetData

func (ds ContextData) GetData() ContextData

func (ContextData) MergeFrom

func (ds ContextData) MergeFrom(other ContextData) ContextData

type ContextDataProvider

type ContextDataProvider interface {
	GetData() ContextData
}

type RequestContext

type RequestContext interface {
	context.Context
	RequestDataStore
}

func FromContext

func FromContext(ctx context.Context) RequestContext

func NewRequestContextForTest

func NewRequestContextForTest(parentCtx context.Context) RequestContext

NewRequestContextForTest creates a new RequestContext for testing purposes It doesn't add the context to the process manager, nor do cleanup

type RequestDataStore

type RequestDataStore interface {
	GetData() ContextData
	SetContextValue(k, v any)
	GetContextValue(key any) any
	AddCleanUp(f func())
	AddCloser(c io.Closer)
}

RequestDataStore is a short-lived context-related object that is used to store request-specific data.

func GetRequestDataStore

func GetRequestDataStore(ctx context.Context) RequestDataStore

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL