correlation_id

package
v4.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const HeaderName = "Correlation-Id"

Variables

View Source
var DefaultIdGenerator = NewRandomIdGenerator(
	rand.New(
		NewLockedSource(
			rand.NewSource(
				time.Now().UTC().UnixNano(),
			),
		),
	),
)

Functions

This section is empty.

Types

type Config

type Config struct {
	HeaderName  string
	IdGenerator func(*http.Request) string
}

func GetConfig

func GetConfig(options ...Option) *Config

GetConfig returns a new correlation configuration with all options applied

type LockedSource

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

LockedSource is a copy of private go lockedSource https://github.com/golang/go/blob/master/src/math/rand/rand.go#L374

func NewLockedSource

func NewLockedSource(src rand.Source) *LockedSource

func (*LockedSource) Int63

func (r *LockedSource) Int63() (n int64)

func (*LockedSource) Seed

func (r *LockedSource) Seed(seed int64)

func (*LockedSource) Uint64

func (r *LockedSource) Uint64() (n uint64)

type Option

type Option func(*Config)

Option defines a correlationId middleware/tripperware configuration option

func WithHeaderName

func WithHeaderName(headerName string) Option

WithHeaderName will configure HeaderName correlation option

func WithIdGenerator

func WithIdGenerator(idGenerator func(*http.Request) string) Option

WithIdGenerator will configure IdGenerator correlation option

type RandomIdGenerator

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

func NewRandomIdGenerator

func NewRandomIdGenerator(rand *rand.Rand) *RandomIdGenerator

func (*RandomIdGenerator) Generate

func (rg *RandomIdGenerator) Generate(length int) string

Jump to

Keyboard shortcuts

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