service

package
v0.13.14 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplicationIsRunning

func ApplicationIsRunning(ctx context.Context) (ok bool)

func CanAccessInternal

func CanAccessInternal(ctx context.Context) (ok bool)

func Fork

func Fork(ctx context.Context, task Task)

func GetApplicationId

func GetApplicationId(ctx context.Context) (appId string)

func GetLog

func GetLog(ctx context.Context) (log logs.Logger)

func GetOutboundChannel

func GetOutboundChannel(ctx context.Context, listener string, name string) (channel listeners.OutboundChannel, has bool)

func SetLog

func SetLog(ctx context.Context, log logs.Logger) context.Context

func SetRequest

func SetRequest(ctx context.Context, r Request) context.Context

func SetTracer

func SetTracer(ctx context.Context) context.Context

func TODO added in v0.13.11

func TODO(ctx context.Context, ep Endpoints) context.Context

func TryFork

func TryFork(ctx context.Context, task Task) (ok bool)

Types

type Abstract

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

func NewAbstract

func NewAbstract(name string, internal bool, components ...Component) Abstract

func (*Abstract) Build

func (svc *Abstract) Build(options Options) (err error)

func (*Abstract) Close

func (svc *Abstract) Close()

func (*Abstract) Components

func (svc *Abstract) Components() (components map[string]Component)

func (*Abstract) Internal

func (svc *Abstract) Internal() (internal bool)

func (*Abstract) Log

func (svc *Abstract) Log() (log logs.Logger)

func (*Abstract) Name

func (svc *Abstract) Name() (name string)

type Argument

type Argument interface {
	json.Marshaler
	json.Unmarshaler
	As(v interface{}) (err errors.CodeError)
}

func EmptyArgument

func EmptyArgument() (arg Argument)

func NewArgument

func NewArgument(v interface{}) (arg Argument)

type Barrier

type Barrier interface {
	Do(ctx context.Context, key string, fn func() (result interface{}, err errors.CodeError)) (result interface{}, err errors.CodeError, shared bool)
	Forget(ctx context.Context, key string)
}

type Component

type Component interface {
	Name() (name string)
	Build(options ComponentOptions) (err error)
	Close()
}

func GetComponent

func GetComponent(ctx context.Context, key string) (v Component, has bool)

type ComponentOptions

type ComponentOptions struct {
	Log    logs.Logger
	Config configures.Config
}

type Document

type Document interface {
	Name() (name string)
	Description() (description string)
	Fns() []FnDocument
	Elements() (elements map[string]ElementDocument)
}

type ElementDocument

type ElementDocument interface {
	Key() (v string)
	Schema() (schema *oas.Schema)
}

type Empty

type Empty struct{}

Empty @name Empty @description Empty

type Endpoint

type Endpoint interface {
	Request(ctx context.Context, fn string, argument Argument) (result Result)
}

func GetEndpoint

func GetEndpoint(ctx context.Context, name string) (v Endpoint, has bool)

func GetExactEndpoint

func GetExactEndpoint(ctx context.Context, name string, id string) (v Endpoint, has bool)

type EndpointDiscovery

type EndpointDiscovery interface {
	Get(ctx context.Context, service string) (endpoint Endpoint, has bool)
	GetExact(ctx context.Context, service string, id string) (endpoint Endpoint, has bool)
}

type Endpoints

type Endpoints interface {
	Handler
	Mount(svc Service)
	RegisterOutboundChannels(name string, channels listeners.OutboundChannels)
	Documents() (v map[string]Document)
	SetupContext(ctx context.Context) context.Context
	Close()
}

func NewEndpoints

func NewEndpoints(options EndpointsOptions) (v Endpoints)

type EndpointsOptions

type EndpointsOptions struct {
	AppId                 string
	Running               *commons.SafeFlag
	Log                   logs.Logger
	MaxWorkers            int
	MaxIdleWorkerDuration time.Duration
	HandleTimeout         time.Duration
	Barrier               Barrier
	Discovery             EndpointDiscovery
}

type FnDocument

type FnDocument interface {
	Name() (name string)
	Title() (title string)
	Description() (description string)
	Authorization() (has bool)
	Deprecated() (deprecated bool)
	Argument() (argument ElementDocument)
	Result() (result ElementDocument)
}

type FutureResult

type FutureResult interface {
	ResultWriter
	Result
}

func NewResult

func NewResult() FutureResult

type Handler

type Handler interface {
	Handle(ctx context.Context, r Request) (v interface{}, err errors.CodeError)
}

type Listenable

type Listenable interface {
	Service
	Sharing() (ok bool)
	Listen(ctx context.Context) (err error)
}

type Metric

type Metric struct {
	Service   string        `json:"service"`
	Fn        string        `json:"fn"`
	Succeed   bool          `json:"succeed"`
	ErrorCode int           `json:"errorCode"`
	ErrorName string        `json:"errorName"`
	Latency   time.Duration `json:"latency"`
}

type Options

type Options struct {
	Log    logs.Logger
	Config configures.Config
}

type Request

type Request interface {
	Id() (id string)
	Internal() (ok bool)
	Authorization() (v string)
	RemoteIp() (v string)
	User() (user RequestUser)
	SetUser(id string, attr *json.Object)
	Local() (local RequestLocal)
	Header() (header RequestHeader)
	Fn() (service string, fn string)
	Argument() (argument Argument)
	Hash() (code uint64)
}

func GetRequest

func GetRequest(ctx context.Context) (r Request, has bool)

func NewInternalRequest

func NewInternalRequest(service string, fn string, arg interface{}) (r Request, err errors.CodeError)

func NewRequest

func NewRequest(req *http.Request) (r Request, err errors.CodeError)

type RequestHeader

type RequestHeader interface {
	Contains(key string) (ok bool)
	Get(key string) (value string)
	Values(key string) (values []string)
	Raw() (v http.Header)
}

func NewRequestHeader

func NewRequestHeader(value http.Header) RequestHeader

type RequestLocal

type RequestLocal interface {
	json.Marshaler
	Scan(key string, value interface{}) (has bool, err errors.CodeError)
	Put(key string, value interface{})
	Remove(key string)
}

func NewRequestLocal added in v0.12.6

func NewRequestLocal() (v RequestLocal)

type RequestUser

type RequestUser interface {
	json.Marshaler
	json.Unmarshaler
	Authenticated() (ok bool)
	Id() (id string)
	IntId() (id int64)
	Attributes() (attributes *json.Object)
}

func GetRequestUser added in v0.13.7

func GetRequestUser(ctx context.Context) (user RequestUser, authenticated bool)

func NewRequestUser

func NewRequestUser(id string, attributes *json.Object) (u RequestUser)

type Result

type Result interface {
	Get(ctx context.Context, v interface{}) (has bool, err errors.CodeError)
	Value(ctx context.Context) (value interface{}, has bool, err errors.CodeError)
}

type ResultWriter

type ResultWriter interface {
	Succeed(v interface{})
	Failed(err errors.CodeError)
}

type Service

type Service interface {
	Build(options Options) (err error)
	Name() (name string)
	Internal() (internal bool)
	Components() (components map[string]Component)
	Document() (doc Document)
	Handle(context context.Context, fn string, argument Argument) (v interface{}, err errors.CodeError)
	Close()
}

Service 管理 Fn 的服务

type Span

type Span interface {
	Id() (v string)
	TracerId() (v string)
	Finish()
	AddTag(key string, value string)
	Tags() (v map[string]string)
	StartAT() (v time.Time)
	FinishedAT() (v time.Time)
	Latency() (v time.Duration)
	Parent() (v Span)
	Children() (v []Span)
	AppendChild(children ...Span)
}

func DecodeSpan

func DecodeSpan(p []byte) (v Span, err errors.CodeError)

type Task

type Task interface {
	Name() (name string)
	Execute(ctx context.Context)
}

type Tracer

type Tracer interface {
	Id() (id string)
	StartSpan(service string, fn string) (span Span)
	Span() (span Span)
}

func GetTracer

func GetTracer(ctx context.Context) (t Tracer, has bool)

func NewTracer

func NewTracer(id string) Tracer

Directories

Path Synopsis
builtin

Jump to

Keyboard shortcuts

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