ctx

package
v0.16.5 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTimeBasedID added in v0.16.4

func GenerateTimeBasedID() string

func GetReqId

func GetReqId(c context.Context) string

GetReqId extract request id from given context. This is a shortcut for Get with ReqId to get the request id from given context.

func NewFromQueue added in v0.12.0

func NewFromQueue(sig string, q ...any) context.Context

NewFromQueue capture request/task id from given queue value in job, also set given signature as signature path in metadata context then return the context.

This function expect the request id is in the first argument, and can be safely used if sending the job to queue using ToQueue.

func NewFromWorker added in v0.12.0

func NewFromWorker(sig, reqId string) context.Context

NewFromWorker return new context that has given signature and request id as the metadata inside the context.

func SetFromConsoleCtx added in v0.16.4

func SetFromConsoleCtx(c console.Context)

func SetFromRequestHeader

func SetFromRequestHeader(c http.Context)

SetFromRequestHeader set any available metadata from given http context in the request header.

func SetHTTPRequestHeader added in v0.12.0

func SetHTTPRequestHeader(r *http.Request)

func ToQueue added in v0.12.0

func ToQueue(c context.Context) (out []queue.Arg)

ToQueue append request id from given context to queue.Arg.

Types

type Metadata

type Metadata struct {
	Authorization   string
	UserAgent       string
	CacheControl    string
	ForwardedFor    string
	RequestFrom     string
	DeviceId        string
	App             string
	VersionApp      string
	ReqId           string
	ReqTags         string
	ReqUser         string
	ReqNama         string
	ReqKodeJabatan  string
	ReqNamaJabatan  string
	ReqKodeUker     string
	ReqNamaUker     string
	ReqJenisUker    string
	ReqKodeMainUker string
	ReqKodeRegion   string
	PathGateway     string
	ApiKey          string
	UrlPath         string // UrlPath may contain the url path information coming from http request
	SignaturePath   string // SignaturePath may contain the signature command from artisan command
}

Metadata holds any request-scoped shared data within brispot microservice.

func Get added in v0.5.0

func Get(ctx context.Context) Metadata

Get retrieve Metadata from given context with key from this pkg.

Jump to

Keyboard shortcuts

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