metadata

package
v0.0.0-...-d80f745 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CtxUidKey        = "CtxUidKey"
	CtxSessIdKey     = "CtxSessIdKey"
	CtxClientAddrKey = "CtxClientAddrKey"
	CtxClientIpKey   = "CtxClientIpKey"
)

Variables

View Source
var (
	RpcMdHolders = []GrpcMdHolder{
		UidMdInOut{},
		ClientIpInOut{},
		ClientAddrInOut{},
	}
)

Functions

func ClientAddr

func ClientAddr(ctx context.Context) string

func ClientIp

func ClientIp(ctx context.Context) string

func RpcWithClientAddr

func RpcWithClientAddr(ctx context.Context, addr string) context.Context

func RpcWithClientIp

func RpcWithClientIp(ctx context.Context, ip string) context.Context

func RpcWithSessId

func RpcWithSessId(ctx context.Context, sessId string) context.Context

func RpcWithUid

func RpcWithUid(ctx context.Context, uid uint64) context.Context

func SessId

func SessId(ctx context.Context) string

func Uid

func Uid(ctx context.Context) uint64

func WithClientAddr

func WithClientAddr(ctx context.Context, addr string) context.Context

func WithClientIp

func WithClientIp(ctx context.Context, ip string) context.Context

func WithSessId

func WithSessId(ctx context.Context, sessId string) context.Context

func WithUid

func WithUid(ctx context.Context, uid uint64) context.Context

Types

type ClientAddrInOut

type ClientAddrInOut struct{}

func (ClientAddrInOut) Extract

func (ClientAddrInOut) Inject

type ClientIpInOut

type ClientIpInOut struct{}

func (ClientIpInOut) Extract

func (ClientIpInOut) Inject

func (ij ClientIpInOut) Inject(ctx context.Context) context.Context

type GrpcMdHolder

type GrpcMdHolder interface {
	MdInjector
	MdExtractor
}

type MdExtractor

type MdExtractor interface {
	Extract(ctx context.Context, md grpcmetadata.MD) context.Context
}

type MdInjector

type MdInjector interface {
	// 从ctx中取出value放入metadata中并重新设置回ctx中
	Inject(ctx context.Context) context.Context
}

type UidMdInOut

type UidMdInOut struct{}

func (UidMdInOut) Extract

func (ij UidMdInOut) Extract(ctx context.Context, md grpcmetadata.MD) context.Context

func (UidMdInOut) Inject

func (ij UidMdInOut) Inject(ctx context.Context) context.Context

Jump to

Keyboard shortcuts

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