simbaContext

package
v0.29.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	LoggerKey          LoggerContextKey  = "logger"
	TraceIDKey         TraceIDContextKey = "traceId"
	TraceIDHeader      string            = "X-Trace-Id"
	RequestSettingsKey RequestContextKey = "requestSettings"
)

Variables

This section is empty.

Functions

func CopyDefault added in v0.29.3

func CopyDefault(src context.Context) context.Context

CopyDefault creates a new context by copying the values added by simba by default, such as trace ID and logger.

func GetTraceID added in v0.27.5

func GetTraceID(ctx context.Context) string

GetTraceID retrieves the trace ID from the context. If no trace ID is present, it returns an empty string.

func WithExistingOrNewTraceID added in v0.27.5

func WithExistingOrNewTraceID(ctx context.Context) context.Context

WithExistingOrNewTraceID returns a context with a trace ID. If the context already has a trace ID, it is reused.

func WithTraceID added in v0.27.5

func WithTraceID(ctx context.Context, traceID string) context.Context

WithTraceID returns a context with the provided trace ID.

func WithTraceIDLogger added in v0.27.6

func WithTraceIDLogger(ctx context.Context) context.Context

WithTraceIDLogger returns a context with a logger that includes the trace ID.

Types

type ContextCopier added in v0.29.3

type ContextCopier struct {
	// contains filtered or unexported fields
}

ContextCopier builds a new context by copying selected values from a source context.

func NewContextCopier added in v0.29.3

func NewContextCopier(src context.Context) *ContextCopier

NewContextCopier creates a new context copier starting with a background context.

func (*ContextCopier) Build added in v0.29.3

func (c *ContextCopier) Build() context.Context

Build finalizes the context copying and returns the new context.

func (*ContextCopier) WithLogger added in v0.29.3

func (c *ContextCopier) WithLogger() *ContextCopier

WithLogger copies the logger from the source context.

func (*ContextCopier) WithTraceID added in v0.29.3

func (c *ContextCopier) WithTraceID() *ContextCopier

WithTraceID copies the trace ID from the source context.

func (*ContextCopier) WithValue added in v0.29.3

func (c *ContextCopier) WithValue(key any) *ContextCopier

WithValue copies a specific value from the source context if it exists.

type LoggerContextKey

type LoggerContextKey string

type RequestContextKey

type RequestContextKey string

type TraceIDContextKey added in v0.27.2

type TraceIDContextKey string

Jump to

Keyboard shortcuts

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