Documentation
¶
Index ¶
- Constants
- Variables
- func Arguments(name string, extends ...Vars) Vars
- func AssetDir(name string) ([]fs.DirEntry, error)
- func AssetFS(fss ...fs.FS) fs.FS
- func AssetFile(name string) ([]byte, error)
- func AssetStat(name string) (fs.FileInfo, error)
- func Broadcast(name string, value Map) error
- func CodecDigitAlphabet() string
- func CodecLength() int
- func CodecSalt() string
- func CodecTextAlphabet() string
- func Decode(name string, data Any, obj Any) (Any, error)
- func DecodeInt64(v string) (int64, error)
- func DecodeInt64Slice(v string) ([]int64, error)
- func DecodeTextBytes(v string) ([]byte, error)
- func Decrypt(name string, obj Any) (Any, error)
- func Dispatch(name string, value Map) error
- func Encode(name string, v Any) (Any, error)
- func EncodeInt64(v int64) (string, error)
- func EncodeInt64Slice(v []int64) (string, error)
- func EncodeTextBytes(v []byte) (string, error)
- func Encrypt(name string, obj Any) (string, error)
- func Enqueue(name string, value Map) error
- func ErrorResult(err error) Res
- func Execute(name string, values ...Map) (Map, Res)
- func Expressions(name string, defs ...string) []string
- func Extension(mime string, defs ...string) string
- func Generate(prefixs ...string) string
- func GenerateTokenID(lengths ...int) string
- func Go(profile ...string)
- func Identity() infragoIdentity
- func Invoke(name string, values ...Map) (Map, Res)
- func InvokeFail(name string, values ...Map) bool
- func InvokeList(name string, values ...Map) (Map, []Map)
- func InvokeOK(name string, values ...Map) bool
- func Invokes(name string, values ...Map) ([]Map, Res)
- func Invoking(name string, offset, limit int64, values ...Map) (int64, []Map)
- func IsRetry(res Res) bool
- func Languages() map[string]Language
- func Mapping(config Vars, data Map, value Map, argn bool, pass bool, ...) Res
- func Marshal(name string, obj Any) ([]byte, error)
- func Match(regular, value string) bool
- func Mimetype(ext string, defs ...string) string
- func Node() string
- func Override(args ...bool) bool
- func Prepare(profile ...string)
- func Publish(name string, value Map) error
- func Ready(profile ...string)
- func Register(args ...Any)
- func RegisterProfile(key string, profile Profile)
- func Request(name string, value Map, timeout ...time.Duration) (Map, Res)
- func Result(code int, status string, text string) Res
- func ResultGroup(name string, bases ...int) *resultGroup
- func Results(langs ...string) map[Status]string
- func RetryResult(res Res, args ...Any) Res
- func Role() string
- func Rolecast(name string, value Map) error
- func Run(profile ...string)
- func Scope(name string) *registerScope
- func Sequence() int64
- func Setting() Map
- func StateCode(name string, defs ...int) int
- func StatusCode(name string, defs ...int) int
- func String(lang, name string, args ...Any) string
- func SyncToggle(name string, values ...Map)
- func Toggle(name string, values ...Map)
- func TraceAttrs(service, kind, entry string, attrs ...Map) Map
- func Types() map[string]Type
- func Unmarshal(name string, data []byte, obj Any) error
- type BusHook
- type Codec
- type Codecs
- type ConfigHook
- type Context
- type DecodeFunc
- type EncodeFunc
- type Host
- type Language
- type Library
- type Message
- type Messages
- type Meta
- func (m *Meta) Authed() bool
- func (m *Meta) Begin(name string, attrs ...Map) TraceSpan
- func (m *Meta) Broadcast(name string, value Map) error
- func (m *Meta) Context() context.Context
- func (m *Meta) Dispatch(name string, value Map) error
- func (m *Meta) Enqueue(name string, value Map) error
- func (m *Meta) Execute(name string, values ...Map) Map
- func (m *Meta) Invoke(name string, values ...Map) Map
- func (m *Meta) InvokeFail(name string, values ...Map) bool
- func (m *Meta) InvokeList(name string, values ...Map) (Map, []Map)
- func (m *Meta) InvokeOK(name string, values ...Map) bool
- func (m *Meta) Invokes(name string, values ...Map) []Map
- func (m *Meta) Invoking(name string, offset, limit int64, values ...Map) (int64, []Map)
- func (m *Meta) Language(v ...string) string
- func (m *Meta) Library(name string, settings ...Map) *libraryInvoker
- func (m *Meta) Metadata(data ...Metadata) Metadata
- func (m *Meta) NewSign(auth bool, payload Map, expires ...time.Duration) string
- func (m *Meta) NewSignAt(auth bool, payload Map, begin time.Time, expires ...time.Duration) string
- func (m *Meta) ParentSpanId(id ...string) string
- func (m *Meta) ParseTraceParent(traceparent string) bool
- func (m *Meta) Payload() Map
- func (m *Meta) PopSpanFrame() (string, string, bool)
- func (m *Meta) Publish(name string, value Map) error
- func (m *Meta) PushSpanFrame(prevSpanId, prevParentId string)
- func (m *Meta) Request(name string, value Map, timeout ...time.Duration) Map
- func (m *Meta) Result(res ...Res) Res
- func (m *Meta) RevokeCurrentToken(expires ...int64) error
- func (m *Meta) RevokeCurrentTokenID(expires ...int64) error
- func (m *Meta) RevokeToken(token string, expires ...int64) error
- func (m *Meta) RevokeTokenID(tokenID string, expires ...int64) error
- func (m *Meta) Rolecast(name string, value Map) error
- func (m *Meta) Sign(auth bool, payload Map, expires ...time.Duration) string
- func (m *Meta) SignAt(auth bool, payload Map, begin time.Time, expires ...time.Duration) string
- func (m *Meta) Signed() bool
- func (m *Meta) SpanId(id ...string) string
- func (m *Meta) String(key string, args ...Any) string
- func (m *Meta) Timezone(zones ...*time.Location) *time.Location
- func (m *Meta) Token(v ...string) string
- func (m *Meta) TokenExpires() int64
- func (m *Meta) TokenId() string
- func (m *Meta) Trace(name string, attrs ...Map) error
- func (m *Meta) TraceEntry(entry ...string) string
- func (m *Meta) TraceId(id ...string) string
- func (m *Meta) TraceKind(kind ...string) string
- func (m *Meta) TraceParent() string
- func (m *Meta) Unauthed() bool
- func (m *Meta) Unsigned() bool
- func (m *Meta) Verify(token string) error
- func (m *Meta) WithContext(ctx context.Context) *Meta
- type Metadata
- type Method
- type Methods
- type Mime
- type Mimes
- type Module
- type NodeInfo
- type Profile
- type RegistryComponent
- type Regular
- type Regulars
- type Service
- type ServiceInfo
- type ServiceNode
- type ServiceStats
- type Services
- type State
- type States
- type Status
- type Statuses
- type Strings
- type Token
- type TokenHook
- type TraceHook
- type TraceSpan
- type Trigger
- type Type
- type TypeValidFunc
- type TypeValueFunc
Constants ¶
const ( JSON = "json" XML = "xml" GOB = "gob" TOML = "toml" DIGIT = "digit" DIGITS = "digits" TEXT = "text" TEXTS = "texts" )
const ( INFRAGO = "infrago" DEFAULT = "default" GLOBAL = "global" )
const ( TraceKindMethod = "method" TraceKindService = "service" TraceKindTrigger = "trigger" TraceKindHTTP = "http" TraceKindWeb = "web" TraceKindEvent = "event" TraceKindQueue = "queue" TraceKindCron = "cron" TraceKindCustom = "custom" )
const ( START = "start" STOP = "stop" )
Variables ¶
var ( // ErrInvalidCodec is returned when codec name is unknown. ErrInvalidCodec = errInvalidCodec // ErrInvalidCodecData is returned when codec data is invalid. ErrInvalidCodecData = errInvalidCodecData )
Functions ¶
func AssetFS ¶ added in v0.7.0
AssetFS sets/gets global asset filesystem. call AssetFS(fsys) to set; call AssetFS() to get.
func CodecDigitAlphabet ¶ added in v0.8.1
func CodecDigitAlphabet() string
CodecDigitAlphabet returns configured digit alphabet.
func CodecLength ¶ added in v0.8.1
func CodecLength() int
CodecLength returns configured encoded length.
func CodecTextAlphabet ¶ added in v0.8.1
func CodecTextAlphabet() string
CodecTextAlphabet returns configured text alphabet.
func DecodeInt64 ¶ added in v0.8.1
DecodeInt64 decodes one int64 using current codec config.
func DecodeInt64Slice ¶ added in v0.8.1
DecodeInt64Slice decodes int64 slice using current codec config.
func DecodeTextBytes ¶ added in v0.8.1
DecodeTextBytes decodes bytes using current codec text config.
func EncodeInt64 ¶ added in v0.8.1
EncodeInt64 encodes one int64 using current codec config.
func EncodeInt64Slice ¶ added in v0.8.1
EncodeInt64Slice encodes int64 slice using current codec config.
func EncodeTextBytes ¶ added in v0.8.1
EncodeTextBytes encodes bytes using current codec text config.
func ErrorResult ¶ added in v0.7.0
func ErrorResult(err error) Res
ErrorResult exposes error-to-Res conversion.
func Execute ¶
func Execute(name string, values ...Map) (Map, Res)
Execute executes one local method only.
func GenerateTokenID ¶ added in v0.10.0
GenerateTokenID returns a random hex token id with configurable length. Default length is 16.
func Invoke ¶ added in v0.7.0
func Invoke(name string, values ...Map) (Map, Res)
Invoke executes one entry as a new request context.
func InvokeFail ¶ added in v0.7.0
InvokeFail executes one entry and returns whether result is failed.
func InvokeList ¶ added in v0.12.0
func InvokeList(name string, values ...Map) (Map, []Map)
InvokeList executes one entry and returns response data with parsed "items" list.
func Invokes ¶ added in v0.7.0
func Invokes(name string, values ...Map) ([]Map, Res)
Invokes executes one entry and returns response items list.
func Invoking ¶ added in v0.7.0
Invoking executes one entry and returns paged items with total count.
func IsRetry ¶ added in v0.13.0
func IsRetry(res Res) bool
IsRetry reports whether one result is marked as retryable.
func Prepare ¶ added in v0.7.0
func Prepare(profile ...string)
Prepare initializes and opens modules without starting them.
func RegisterProfile ¶ added in v0.7.0
func ResultGroup ¶
func RetryResult ¶ added in v0.13.0
func RetryResult(res Res, args ...Any) Res
RetryResult marks one result as retryable and optionally overrides message args.
func Run ¶ added in v0.7.0
func Run(profile ...string)
Run starts the full lifecycle and blocks until stop.
func Scope ¶ added in v0.11.1
func Scope(name string) *registerScope
Scope creates a named registration scope so names can omit repeated prefix.
func SyncToggle ¶
func SyncToggle(name string, values ...Map)
func TraceAttrs ¶ added in v0.7.0
func TraceAttrs(service, kind, entry string, attrs ...Map) Map
TraceAttrs builds a normalized trace attrs map.
Types ¶
type BusHook ¶ added in v0.7.0
type BusHook interface {
Request(meta *Meta, name string, value base.Map, timeout time.Duration) (base.Map, base.Res)
Broadcast(meta *Meta, name string, value base.Map) error
Rolecast(meta *Meta, name string, value base.Map) error
Dispatch(meta *Meta, name string, value base.Map) error
// compatibility aliases
Publish(meta *Meta, name string, value base.Map) error
Enqueue(meta *Meta, name string, value base.Map) error
Stats() []ServiceStats
ListNodes() []NodeInfo
ListServices() []ServiceInfo
}
type Codec ¶
type Codec struct {
Name string
Text string
Alias []string
Encode EncodeFunc
Decode DecodeFunc
}
type ConfigHook ¶ added in v0.7.0
type Context ¶
type Context struct {
*Meta
Name string
Config *coreEntry
Setting Map
Value Map
Args Map
// contains filtered or unexported fields
}
Context carries invocation data for method/service.
type DecodeFunc ¶
type DecodeFunc func(d Any, v Any) (Any, error)
type EncodeFunc ¶
type EncodeFunc func(v Any) (Any, error)
type Host ¶ added in v0.7.0
type Host interface {
InvokeLocal(meta *Meta, name string, value Map) (Map, Res, bool)
InvokeLocalMethod(meta *Meta, name string, value Map) (Map, Res, bool)
InvokeLocalService(meta *Meta, name string, value Map, settings ...Map) (Map, Res, bool)
InvokeLocalMessage(meta *Meta, name string, value Map) (Map, Res, bool)
RegisterLocal(name string, value Any)
}
type Language ¶
type Language struct {
// Name 语言名称
Name string
// Desc 语言说明
Desc string
// Accepts 匹配的语言
// 比如,znCN, zh, zh-CN 等自动匹配
Accepts []string
// Strings 当前语言是字符串列表
Strings Strings
}
多语言配置
type Library ¶
Library defines a method group with defaults. Example:
Register("mail.sendcloud", Library{
Name: "SendCloud",
Methods: Methods{"send": Method{...}},
})
func (Library) RegistryComponent ¶ added in v0.7.0
type Message ¶ added in v0.13.0
type Message struct {
Name string
Desc string
Nullable bool
Args Vars
Data Vars
Action Any
Setting Map
}
func (Message) RegistryComponent ¶ added in v0.13.0
type Messages ¶ added in v0.13.0
func (Messages) RegistryComponent ¶ added in v0.13.0
type Meta ¶
type Meta struct {
// contains filtered or unexported fields
}
func (*Meta) Invoke ¶
Invoke calls another service (local first, then bus). It stores the result in meta and returns only the data.
func (*Meta) InvokeFail ¶ added in v0.7.0
InvokeFail executes one call and returns whether result is failed.
func (*Meta) InvokeList ¶ added in v0.12.0
InvokeList executes one call and also returns parsed "items" list from response data.
func (*Meta) InvokeOK ¶ added in v0.7.0
InvokeOK executes one call and returns whether result is OK.
func (*Meta) NewSign ¶
NewSign issues token with a new token id. expires is optional duration, begin defaults to current time.
func (*Meta) NewSignAt ¶ added in v0.9.0
NewSignAt issues token with a new token id and custom begin time. expires is optional duration.
func (*Meta) ParentSpanId ¶ added in v0.7.0
func (*Meta) ParseTraceParent ¶ added in v0.7.0
ParseTraceParent parses W3C traceparent: 00-<traceid>-<spanid>-<flags>.
func (*Meta) PushSpanFrame ¶ added in v0.7.0
func (*Meta) RevokeCurrentToken ¶ added in v0.26.0
RevokeCurrentToken revokes the current raw token, defaulting to current token expiry.
func (*Meta) RevokeCurrentTokenID ¶ added in v0.26.0
RevokeCurrentTokenID revokes the current token id, defaulting to current token expiry.
func (*Meta) RevokeToken ¶ added in v0.9.0
RevokeToken revokes one raw token.
func (*Meta) RevokeTokenID ¶ added in v0.9.0
RevokeTokenID revokes one token id.
func (*Meta) Sign ¶
Sign issues token with current token id. expires is optional duration, begin defaults to current time.
func (*Meta) SignAt ¶ added in v0.9.0
SignAt issues token with current token id and custom begin time. expires is optional duration.
func (*Meta) TokenExpires ¶ added in v0.26.0
TokenExpires returns current token expiry as a Unix timestamp.
func (*Meta) TraceEntry ¶ added in v0.7.0
func (*Meta) TraceParent ¶ added in v0.7.0
TraceParent builds W3C traceparent using current trace/span ids.
type Method ¶
type Method struct {
Name string
Desc string
Nullable bool
Args Vars
Data Vars
Action Any
Setting Map
}
func (Method) RegistryComponent ¶ added in v0.7.0
type Methods ¶ added in v0.7.0
func (Methods) RegistryComponent ¶ added in v0.7.0
type Module ¶
type Module interface {
Register(string, Any)
Config(Map)
Setup()
Open()
Start()
Stop()
Close()
}
type NodeInfo ¶ added in v0.7.0
type NodeInfo struct {
Project string `json:"project"`
Node string `json:"node"`
Role string `json:"role"`
Profile string `json:"profile"`
Services []string `json:"services"`
Updated int64 `json:"updated"`
}
NodeInfo contains one online node's exposed service set.
type RegistryComponent ¶ added in v0.7.0
type RegistryComponent interface {
RegistryComponent() string
}
type Service ¶
type Service struct {
Name string
Desc string
Nullable bool
Args Vars
Data Vars
Action Any
Retry []time.Duration
Setting Map
}
func (Service) RegistryComponent ¶ added in v0.7.0
type ServiceInfo ¶ added in v0.7.0
type ServiceInfo struct {
Service string `json:"service"`
Name string `json:"name"`
Desc string `json:"desc"`
Updated int64 `json:"updated"`
Instances int `json:"instances"`
Nodes []ServiceNode `json:"nodes"`
}
ServiceInfo is a service-centric online view.
type ServiceNode ¶ added in v0.7.0
type ServiceNode struct {
Node string `json:"node"`
Role string `json:"role"`
Profile string `json:"profile"`
}
ServiceNode indicates one node serving a service.
type ServiceStats ¶ added in v0.7.0
type ServiceStats struct {
Name string `json:"name"`
Version string `json:"version"`
NumRequests int `json:"num_requests"`
NumErrors int `json:"num_errors"`
TotalLatency int64 `json:"total_latency_ms"`
AvgLatency int64 `json:"avg_latency_ms"`
}
ServiceStats contains service statistics.
type Services ¶ added in v0.7.0
func (Services) RegistryComponent ¶ added in v0.7.0
type Trigger ¶
type Trigger struct {
Name string
Desc string
Nullable bool
Args Vars
Data Vars
Action func(*Context)
}
func (Trigger) RegistryComponent ¶ added in v0.7.0
type Type ¶
type Type struct {
// Name 类型名称
Name string
// Desc 类型说明
Desc string
// Alias 类型别名
Alias []string
// Valid 类型检查方法
Valid TypeValidFunc
// Value 类型值包装方法
Value TypeValueFunc
}
Type 类型定义
type TypeValidFunc ¶
type TypeValidFunc func(Any, Var) bool
type TypeValueFunc ¶
type TypeValueFunc func(Any, Var) Any