requestid

package
v0.0.0-...-c0c742b Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Container = &RequestIdContainer{}
)

Initialize a request id container singleton instance

Functions

func InitializeRequestIdGenerator

func InitializeRequestIdGenerator(config *settings.Config) error

InitializeRequestIdGenerator initializes the current request id generator according to the config

Types

type DefaultRequestIdGenerator

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

DefaultRequestIdGenerator represents default request id generator

func NewDefaultRequestIdGenerator

func NewDefaultRequestIdGenerator(config *settings.Config) (*DefaultRequestIdGenerator, error)

NewDefaultRequestIdGenerator returns a new default request id generator

func (*DefaultRequestIdGenerator) GenerateRequestId

func (r *DefaultRequestIdGenerator) GenerateRequestId(clientIpAddr string) string

GenerateRequestId returns a new request id

func (*DefaultRequestIdGenerator) GetCurrentInstanceUniqId

func (r *DefaultRequestIdGenerator) GetCurrentInstanceUniqId() uint16

GetCurrentInstanceUniqId returns current application instance unique id

func (*DefaultRequestIdGenerator) GetCurrentServerUniqId

func (r *DefaultRequestIdGenerator) GetCurrentServerUniqId() uint16

GetCurrentServerUniqId returns current server unique id

func (*DefaultRequestIdGenerator) ParseRequestIdInfo

func (r *DefaultRequestIdGenerator) ParseRequestIdInfo(requestId string) (*RequestIdInfo, error)

ParseRequestIdInfo returns a info struct which contains all information in request id

type RequestIdContainer

type RequestIdContainer struct {
	Current RequestIdGenerator
}

RequestIdContainer contains the current request id generator

func (*RequestIdContainer) GenerateRequestId

func (u *RequestIdContainer) GenerateRequestId(clientIpAddr string) string

GenerateRequestId returns a new request id by the current request id generator

type RequestIdGenerator

type RequestIdGenerator interface {
	GenerateRequestId(clientIpAddr string) string
	GetCurrentServerUniqId() uint16
	GetCurrentInstanceUniqId() uint16
}

RequestIdGenerator is common request generator interface

type RequestIdInfo

type RequestIdInfo struct {
	ServerUniqId        uint16
	InstanceUniqId      uint16
	SecondsElapsedToday uint32
	RandomNumber        uint32
	RequestSeqId        uint32
	IsClientIpv6        bool
	ClientIp            uint32
}

RequestIdInfo represents a struct which has all information in request id

Jump to

Keyboard shortcuts

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