common

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: MIT Imports: 0 Imported by: 0

README

common

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ApiCtxKey = ContextKey{}

Functions

This section is empty.

Types

type APIContext added in v0.1.0

APIContext combines request and response contexts

type Chain added in v0.1.3

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

func NewChain added in v0.1.3

func NewChain() *Chain

func (*Chain) Append added in v0.1.3

func (c *Chain) Append(middleware func(Handler) Handler)

func (*Chain) Apply added in v0.1.3

func (c *Chain) Apply(h Handler) Handler

type ColumnDataType

type ColumnDataType string

type ContextKey added in v0.1.1

type ContextKey struct{}

type DatabaseType

type DatabaseType string

type GlobalThisReader

type GlobalThisReader interface {
	Input() any
	Env() map[string]any
	Metas() map[string]any
	Session() map[string]any
	RequestHeaders() map[string]any

	Output() any
	ResponseHeaders() map[string]any
}

type Handler added in v0.1.3

type Handler interface {
	Handle(APIContext)
}

type HandlerFunc added in v0.1.3

type HandlerFunc func(APIContext)

func (HandlerFunc) Handle added in v0.1.3

func (h HandlerFunc) Handle(ctx APIContext)

type MutableRequestContext added in v0.1.0

type MutableRequestContext interface {
	SetRequestID(string)
	SetMethod(string)
	SetParams(any)
	SetRawParams([]byte)
	SetMetas(map[string]any)
}

MutableRequestContext allows modification of request context

type MutableResponseContext added in v0.1.0

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

MutableResponseContext allows modification of response context

type PersistenceContext

type PersistenceContext interface {
	GetRepository(entity string) (Repository, error)
	GetAllQueryCount() int64
	CloseAllTxn(error) error
}

type PreparedQuery

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

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

type QueryResult

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

type QueryType

type QueryType string

type Repository

type Repository interface {
	BindNamed(query string, arg any) (string, []any, error)
	Find(query string, args ...any) (map[string]any, error)
	FindAll(query string, args ...any) ([]map[string]any, error)
	Insert(query string, args ...any) (int64, error)
	InsertBatch(query string, args ...any) (int64, error)
	// InsertNamedBatch
	// Deprecated
	InsertNamedBatch(query string, args []any) (int64, error)
	Update(query string, args ...any) (int64, error)
	Delete(query string, args ...any) (int64, error)

	Begin() error
	Commit() error
	Rollback() error

	Exec(query string, args ...any) error

	DriverName() string

	QueryTotal() int64
	SetTraceId(traceId string)
}

type RequestContext added in v0.1.0

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

RequestContext contains request-related information

type ResponseContext added in v0.1.0

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

ResponseContext contains response-related information

type ScriptRunner

type ScriptRunner interface {
	RunScript(globalThis map[string]any, pCtx PersistenceContext, sourceCode string) (any, error)
}

type TableType

type TableType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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