common

package module
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: MIT Imports: 6 Imported by: 0

README

common

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApiCtxKey = ContextKey{}

Functions

func GenerateSpanID added in v0.1.18

func GenerateSpanID() string

GenerateSpanID generates a 64-bit Span ID

func GenerateTraceID added in v0.1.18

func GenerateTraceID() string

GenerateTraceID generates a 128-bit Trace ID

Types

type APIContext added in v0.1.0

APIContext combines request and response contexts

type AsmParam added in v0.1.19

type AsmParam struct {
	Api           string
	Param         []any
	SessionFilter map[string]string
	SessionValues map[string]string
}

type ContextKey added in v0.1.1

type ContextKey struct{}

type DalContext added in v0.1.9

type DalContext struct {
	// Container for transaction management.
	// Ensures that accessing the same database during a single API request uses the same connection,
	// and automatically commits or rolls back transactions when the request ends.
	Container *sync.Map

	TraceID  string
	ParentID string
	SpanID   string

	DebugInfo []map[string]any
}

type Debugger added in v0.2.0

type Debugger interface {
	SetDebugInfo([]map[string]any)
	DebugInfo() []map[string]any
}

type EndpointMetas added in v0.1.22

type EndpointMetas struct {
	Name          string
	SessionFilter map[string]any
	SessionValue  map[string]any
}

type Handler added in v0.1.3

type Handler interface {
	Process(APIContext) error
}

type HandlerFunc added in v0.1.3

type HandlerFunc func(APIContext) error

func (HandlerFunc) Process added in v0.1.13

func (hf HandlerFunc) Process(ctx APIContext) error

type ParsedName added in v0.3.0

type ParsedName struct {
	FullName     string `json:"fullName"` // FullName = EndpointName + ApiName
	EndpointName string `json:"endpointName"`
	ApiName      string `json:"apiName"` // ApiName = EntityName + EntityMethod
	EntityName   string `json:"entityName"`
	EntityMethod string `json:"entityMethod"`
}

func ParseMethodName added in v0.3.0

func ParseMethodName(method string) (*ParsedName, error)

type PreparedQuery

type PreparedQuery struct {
	Query     string `json:"query"`
	Bind      []any  `json:"bind"`
	QueryType string `json:"queryType"`

	CheckPoint      []*PreparedQuery `json:"checkPoint"`
	DatabaseUpdater []*PreparedQuery `json:"databaseUpdater"`
	ResultEnricher  []*PreparedQuery `json:"resultEnricher"`
}

type QueryResult

type QueryResult struct {
	QueryType    string
	LastInsertId int64
	RowsAffected int64
	Row          map[string]any
	Rows         []map[string]any
	Total        int64
}

type RequestContext added in v0.1.0

type RequestContext struct {
	ApiName     string
	RemoteAddr  string
	RemoteHost  string
	RequestTime time.Time
}

type RequestReader added in v0.1.15

type RequestReader interface {
	RequestID() string
	RequestContext() *RequestContext
	Method() string
	Params() any
	RawParams() []byte
	Metas() map[string]any
	EndpointMetas() *EndpointMetas
}

RequestReader contains request-related information

type RequestWriter added in v0.1.15

type RequestWriter interface {
	SetRequestID(string)
	SetMethod(string)
	SetParams(any)
	SetRawParams([]byte)
	SetMetas(map[string]any)
	SetEndpointMetas(*EndpointMetas)
}

RequestWriter allows modification of request-related information

type ResponseReader added in v0.1.15

type ResponseReader interface {
	Result() any
	Err() error
}

ResponseReader contains response-related information

type ResponseWriter added in v0.1.15

type ResponseWriter interface {
	SetResult(any)
	SetErr(error)
}

ResponseWriter allows modification of response-related information

type RunnerContext added in v0.3.0

type RunnerContext struct {
	// Provide the default entity name for getting database connections
	// only when the scripting language is native SQL.
	DefaultEntityName string

	GlobalThis map[string]any

	DalCtx *DalContext
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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