wrappers

package
v0.0.0-...-e04e7a0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG_CA = false

Functions

func CtxCallArgs

func CtxCallArgs(ctx context.Context) cm.CallArgs

func CtxCallId

func CtxCallId(ctx context.Context) cm.CallId

func CtxCaller

func CtxCaller(ctx context.Context) cm.ServiceName

func CtxSetCallArgs

func CtxSetCallArgs(ctx context.Context, ca cm.CallArgs) context.Context

func CtxSetCallId

func CtxSetCallId(ctx context.Context, id cm.CallId) context.Context

func CtxSetCaller

func CtxSetCaller(ctx context.Context, name cm.ServiceName) context.Context

func CtxSetReadOnly

func CtxSetReadOnly(ctx context.Context, readOnly bool) context.Context

func HashCallArgs

func HashCallArgs(app string, method string, input []byte) string

func HashCallArgsWithShard

func HashCallArgsWithShard(app string, method string, input []byte) (string, int)

func InitReqCtx

func InitReqCtx(ctx context.Context, id cm.CallId, ca cm.CallArgs, caller cm.ServiceName, ro bool) context.Context

Helper function that initializes the ctx for the client It's used at the beginning of each request handler so PreReqStart is also merged into this function

func NonROWrapper

func NonROWrapper[ReqType interface{}, RespType interface{}](handler func(context.Context, *ReqType) *RespType) func(http.ResponseWriter, *http.Request)

func PostWrite

func PostWrite(ctx context.Context, key cm.Key)

func PreCall

func PreCall(ctx context.Context, ca cm.CallArgs) (cm.ReturnVal, bool)

This returns true if cache was hit. The caller of this method needs to avoid the call if that is the case.

func PreRead

func PreRead(ctx context.Context, key cm.Key)

Could also happen after read (or at the same time)

func PreReqEnd

func PreReqEnd(ctx context.Context, retVal cm.ReturnVal)

func PreReqStart

func PreReqStart(ctx context.Context)

func PreWrite

func PreWrite(ctx context.Context, key cm.Key)

func ROWrapper

func ROWrapper[ReqType interface{}, RespType interface{}](handler func(context.Context, *ReqType) *RespType) func(http.ResponseWriter, *http.Request)

func ReadOnlyContext

func ReadOnlyContext(ctx context.Context) bool

func SetupCtxFromHTTPReq

func SetupCtxFromHTTPReq(r *http.Request, ro bool) (context.Context, []byte)

Types

type CtxItem

type CtxItem struct {
	Key   string
	Value interface{}
}

type Deps

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

Global variables can be accessed by all threads in Go Use a sync.Map to make it thread-safe

func (*Deps) AddCallDep

func (deps *Deps) AddCallDep(id cm.CallId, ca cm.CallArgs)

func (*Deps) AddKeyDep

func (deps *Deps) AddKeyDep(id cm.CallId, key cm.Key)

func (*Deps) InitDep

func (deps *Deps) InitDep(id cm.CallId)

func (*Deps) PopDeps

func (deps *Deps) PopDeps(id cm.CallId) ([]cm.Key, []cm.CallArgs)

func (*Deps) String

func (deps *Deps) String() string

Just for debugging

Jump to

Keyboard shortcuts

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