gctx

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package gctx wraps context.Context and provides extra context features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CtxId

func CtxId(ctx context.Context) string

CtxId retrieves and returns the context id from context.

func New

func New() context.Context

New creates and returns a context which contains context id.

func WithCtx

func WithCtx(ctx context.Context) context.Context

WithCtx creates and returns a context containing context id upon given parent context `ctx`.

func WithCtxId

func WithCtxId(ctx context.Context, id string) context.Context

WithCtxId creates and returns a context containing context id upon given parent context `ctx`. The generated context id value is specified by parameter `id`.

func WithPrefix

func WithPrefix(ctx context.Context, prefix string) context.Context

WithPrefix creates and returns a context containing context id upon given parent context `ctx`. The generated context id has custom prefix string specified by parameter `prefix`.

Types

type Ctx

type Ctx = context.Context // Ctx is short name alias for context.Context.

type StrKey

type StrKey string // StrKey is a type for warps basic type string as context key.
const (
	// CtxKey is custom tracing context key for context id.
	// The context id a unique string for certain context.
	CtxKey StrKey = "GoFrameCtxId"
)

Jump to

Keyboard shortcuts

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