Documentation
¶
Index ¶
- Variables
- func Abort()
- func CanAccessInternal(ctx context.Context) (ok bool)
- func DataPlate(ctx context.Context) (appId string, appName string, appVersion versions.Version)
- func DefaultConfigRetrieverOption() (option configures.RetrieverOption)
- func EnableCacheControl(ctx context.Context, ttl time.Duration)
- func Fork(ctx context.Context, task Task)
- func GetLog(ctx context.Context) (log logs.Logger)
- func GetSigner(ctx context.Context) (signer *secret.Signer)
- func NewFuture() (p Promise, f Future)
- func RegisterClusterBuilder(name string, builder ClusterBuilder)
- func Running(ctx context.Context) (signal <-chan struct{})
- func SharedLock(ctx context.Context, key []byte, ttl time.Duration) (locker shareds.Locker, err errors.CodeError)
- func SharedStore(ctx context.Context) (store shareds.Store)
- func TryFork(ctx context.Context, task Task) (ok bool)
- type Abstract
- func (svc *Abstract) AppId() (id string)
- func (svc *Abstract) AppName() (name string)
- func (svc *Abstract) AppVersion() (version versions.Version)
- func (svc *Abstract) Barrier(ctx context.Context, name string, arg Argument, ...) (result interface{}, err errors.CodeError)
- func (svc *Abstract) Build(options Options) (err error)
- func (svc *Abstract) Close()
- func (svc *Abstract) Components() (components map[string]Component)
- func (svc *Abstract) Document() (doc *documents.Document)
- func (svc *Abstract) Internal() (internal bool)
- func (svc *Abstract) Log() (log logs.Logger)
- func (svc *Abstract) Name() (name string)
- type Argument
- type AutoMaxProcsConfig
- type Barrier
- type Cluster
- type ClusterBuilder
- type ClusterBuilderOptions
- type ClusterConfig
- type Component
- type ComponentOptions
- type Config
- type Empty
- type Endpoint
- type EndpointDiscovery
- type EndpointDiscoveryGetOption
- type EndpointDiscoveryGetOptions
- type Endpoints
- func (e *Endpoints) Close(ctx context.Context)
- func (e *Endpoints) Deploy(svc Service) (err error)
- func (e *Endpoints) Get(ctx context.Context, service string, options ...EndpointDiscoveryGetOption) (v Endpoint, has bool)
- func (e *Endpoints) Listen(ctx context.Context) (err error)
- func (e *Endpoints) Log() (log logs.Logger)
- func (e *Endpoints) Running() (ok bool)
- func (e *Endpoints) Runtime() (rt *Runtime)
- type EndpointsOptions
- type Future
- type FutureResult
- type Listenable
- type LogConfig
- type Metric
- type Node
- type Nodes
- type Options
- type Promise
- type ProxyConfig
- type RateLimitCounter
- type RateLimitCounterOptions
- type Registration
- func (registration *Registration) Document() (document *documents.Document)
- func (registration *Registration) Internal() (ok bool)
- func (registration *Registration) Key() (key string)
- func (registration *Registration) Name() (name string)
- func (registration *Registration) Request(ctx context.Context, r Request) (future Future)
- func (registration *Registration) RequestSync(ctx context.Context, r Request) (result FutureResult, err errors.CodeError)
- type RegistrationList
- type Registrations
- func (r *Registrations) Add(registration *Registration)
- func (r *Registrations) AddNode(node *Node) (err error)
- func (r *Registrations) Close()
- func (r *Registrations) FetchDocuments(ctx context.Context) (v documents.Documents, err error)
- func (r *Registrations) FetchNodeDocuments(ctx context.Context, node *Node) (v documents.Documents, err error)
- func (r *Registrations) Get(name string, rvs RequestVersions) (registration *Registration, has bool)
- func (r *Registrations) GetExact(name string, id string) (registration *Registration, has bool)
- func (r *Registrations) GetNodeServices(ctx context.Context, node *Node) (names []string, err error)
- func (r *Registrations) List() (values map[string]RegistrationList)
- func (r *Registrations) ListMembers(ctx context.Context) (members Nodes, err error)
- func (r *Registrations) MergeNodes(nodes Nodes) (err error)
- func (r *Registrations) Refresh(ctx context.Context)
- func (r *Registrations) Remove(id string)
- type Request
- type RequestHeader
- func (header RequestHeader) Add(key, value string)
- func (header RequestHeader) Authorization() (authorization string, has bool)
- func (header RequestHeader) Clone() RequestHeader
- func (header RequestHeader) Contains(key string) (ok bool)
- func (header RequestHeader) Del(key string)
- func (header RequestHeader) DeviceId() (id string)
- func (header RequestHeader) DeviceIp() (id string)
- func (header RequestHeader) Empty() bool
- func (header RequestHeader) ForEach(fn func(key string, values []string) (next bool))
- func (header RequestHeader) Get(key string) string
- func (header RequestHeader) Set(key, value string)
- func (header RequestHeader) SetAcceptVersions(rvs RequestVersions)
- func (header RequestHeader) SetDeviceId(id string)
- func (header RequestHeader) SetDeviceIp(ip string)
- func (header RequestHeader) Values(key string) []string
- type RequestLimiterConfig
- type RequestOption
- func WithDeviceId(id string) RequestOption
- func WithDeviceIp(ip string) RequestOption
- func WithInternalRequest() RequestOption
- func WithRequestHeader(header transports.Header) RequestOption
- func WithRequestId(id string) RequestOption
- func WithRequestTrunk(trunk RequestTrunk) RequestOption
- func WithRequestUser(id RequestUserId, attributes *json.Object) RequestOption
- func WithRequestVersions(acceptedVersions RequestVersions) RequestOption
- type RequestOptions
- type RequestTrunk
- type RequestUser
- type RequestUserId
- type RequestVersion
- type RequestVersions
- type Runtime
- func (rt *Runtime) AppId() string
- func (rt *Runtime) AppName() string
- func (rt *Runtime) AppStatus() *Status
- func (rt *Runtime) AppVersion() versions.Version
- func (rt *Runtime) Barrier() Barrier
- func (rt *Runtime) Discovery() EndpointDiscovery
- func (rt *Runtime) RootLog() logs.Logger
- func (rt *Runtime) SetIntoContext(ctx context.Context) context.Context
- func (rt *Runtime) Shared() Shared
- func (rt *Runtime) Signer() *secret.Signer
- func (rt *Runtime) Workers() Workers
- type RuntimeConfig
- type Service
- type ServicesSupplier
- type Shared
- type SharedConfig
- type Span
- func (s *Span) AddTag(key string, value string)
- func (s *Span) AppendChild(children ...*Span)
- func (s *Span) Children() (v []*Span)
- func (s *Span) Finish()
- func (s *Span) FinishedAT() (v time.Time)
- func (s *Span) Id() (v string)
- func (s *Span) Latency() (v time.Duration)
- func (s *Span) Parent() (v *Span)
- func (s *Span) StartAT() (v time.Time)
- func (s *Span) Tags() (v map[string]string)
- func (s *Span) TracerId() (v string)
- type Status
- type TLSConfig
- type Task
- type Tracer
- type TransportConfig
- func (config *TransportConfig) ConvertToTransportsOptions(log logs.Logger, handler transports.Handler) (options transports.Options, err error)
- func (config *TransportConfig) HandlersConfig() (conf configures.Config, err error)
- func (config *TransportConfig) MiddlewaresConfig() (conf configures.Config, err error)
- type TransportHandler
- type TransportHandlerOptions
- type TransportMiddleware
- type TransportMiddlewareOptions
- type TransportOptions
- type Workers
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrServiceOverload = errors.Unavailable("fns: service is overload").WithMeta("fns", "overload") ErrTooEarly = errors.New(http.StatusTooEarly, "***TOO EARLY***", "fns: service is not ready, try later again") ErrDeviceId = errors.Warning("fns: device id was required") ErrNotFound = errors.NotFound("fns: no handlers accept request") )
View Source
var ( ErrSignatureLost = errors.New(488, "***SIGNATURE LOST***", "X-Fns-Signature was required") ErrSignatureUnverified = errors.New(458, "***SIGNATURE INVALID***", "X-Fns-Signature was invalid") ErrSessionOutOfDate = errors.New(468, "***SESSION OUT OF DATE***", "need to create session") )
View Source
var (
ErrTooMayRequest = errors.New(http.StatusTooManyRequests, "***TOO MANY REQUEST***", "fns: too may request, try again later.")
)
Functions ¶
func CanAccessInternal ¶
func DefaultConfigRetrieverOption ¶ added in v0.14.0
func DefaultConfigRetrieverOption() (option configures.RetrieverOption)
func EnableCacheControl ¶ added in v1.0.10
EnableCacheControl use `@cache {ttl}` in service function
func RegisterClusterBuilder ¶ added in v0.14.0
func RegisterClusterBuilder(name string, builder ClusterBuilder)
func SharedLock ¶ added in v0.14.0
Types ¶
type Abstract ¶
type Abstract struct {
// contains filtered or unexported fields
}
func (*Abstract) AppVersion ¶ added in v0.14.0
func (*Abstract) Components ¶
type Argument ¶
type Argument interface { json.Marshaler json.Unmarshaler As(v interface{}) (err errors.CodeError) HashCode() (code uint64) }
func EmptyArgument ¶
func EmptyArgument() (arg Argument)
func NewArgument ¶
func NewArgument(v interface{}) (arg Argument)
type AutoMaxProcsConfig ¶ added in v0.14.0
type Barrier ¶
type Barrier interface { Do(ctx context.Context, key string, fn func() (result interface{}, err errors.CodeError)) (result interface{}, err errors.CodeError) Forget(ctx context.Context, key string) }
func GetBarrier ¶ added in v0.14.0
type ClusterBuilder ¶ added in v0.14.0
type ClusterBuilder func(options ClusterBuilderOptions) (cluster Cluster, err error)
type ClusterBuilderOptions ¶ added in v0.14.0
type ClusterConfig ¶ added in v0.14.0
type Component ¶
type Component interface { Name() (name string) Build(options ComponentOptions) (err error) Close() }
type ComponentOptions ¶
type Config ¶ added in v0.14.0
type Config struct { Runtime *RuntimeConfig `json:"runtime"` Log *LogConfig `json:"log"` Transport *TransportConfig `json:"transport"` Cluster *ClusterConfig `json:"cluster"` Proxy *ProxyConfig `json:"proxy"` Services json.RawMessage `json:"services"` }
type Endpoint ¶
type Endpoint interface { Name() (name string) Internal() (ok bool) Document() (document *documents.Document) Request(ctx context.Context, r Request) (future Future) RequestSync(ctx context.Context, r Request) (result FutureResult, err errors.CodeError) }
func GetEndpoint ¶
type EndpointDiscovery ¶
type EndpointDiscoveryGetOption ¶ added in v0.14.0
type EndpointDiscoveryGetOption func(options *EndpointDiscoveryGetOptions)
func Exact ¶ added in v0.14.0
func Exact(id string) EndpointDiscoveryGetOption
func Native ¶ added in v0.14.0
func Native() EndpointDiscoveryGetOption
func Versions ¶ added in v1.0.10
func Versions(requestVersions RequestVersions) EndpointDiscoveryGetOption
type EndpointDiscoveryGetOptions ¶ added in v0.14.0
type EndpointDiscoveryGetOptions struct {
// contains filtered or unexported fields
}
type Endpoints ¶
type Endpoints struct {
// contains filtered or unexported fields
}
func NewEndpoints ¶
func NewEndpoints(options EndpointsOptions) (v *Endpoints, err error)
type EndpointsOptions ¶
type EndpointsOptions struct { AppId string AppName string AppVersion versions.Version Transport *TransportOptions Proxy *TransportOptions Config configures.Config }
type Future ¶ added in v0.14.0
type Future interface {
Get(ctx context.Context) (result FutureResult, err errors.CodeError)
}
type FutureResult ¶
type ProxyConfig ¶ added in v1.0.5
type ProxyConfig struct { TransportConfig EnableDevMode bool `json:"enableDevMode"` }
type RateLimitCounter ¶ added in v1.0.10
type RateLimitCounterOptions ¶ added in v1.0.10
type RateLimitCounterOptions struct { AppId string AppName string AppVersion versions.Version AppStatus *Status Log logs.Logger Config configures.Config Discovery EndpointDiscovery }
type Registration ¶ added in v0.14.0
type Registration struct {
// contains filtered or unexported fields
}
func (*Registration) Document ¶ added in v0.14.0
func (registration *Registration) Document() (document *documents.Document)
func (*Registration) Internal ¶ added in v0.14.0
func (registration *Registration) Internal() (ok bool)
func (*Registration) Key ¶ added in v0.14.0
func (registration *Registration) Key() (key string)
func (*Registration) Name ¶ added in v0.14.0
func (registration *Registration) Name() (name string)
func (*Registration) Request ¶ added in v0.14.0
func (registration *Registration) Request(ctx context.Context, r Request) (future Future)
func (*Registration) RequestSync ¶ added in v0.14.0
func (registration *Registration) RequestSync(ctx context.Context, r Request) (result FutureResult, err errors.CodeError)
type RegistrationList ¶ added in v1.0.5
type RegistrationList []*Registration
func (RegistrationList) Len ¶ added in v1.0.5
func (list RegistrationList) Len() int
func (RegistrationList) Less ¶ added in v1.0.5
func (list RegistrationList) Less(i, j int) bool
func (RegistrationList) MaxVersion ¶ added in v1.0.5
func (list RegistrationList) MaxVersion() (r *Registration)
func (RegistrationList) MinVersion ¶ added in v1.0.5
func (list RegistrationList) MinVersion() (r *Registration)
func (RegistrationList) Swap ¶ added in v1.0.5
func (list RegistrationList) Swap(i, j int)
type Registrations ¶ added in v0.14.0
type Registrations struct {
// contains filtered or unexported fields
}
func (*Registrations) Add ¶ added in v0.14.0
func (r *Registrations) Add(registration *Registration)
func (*Registrations) AddNode ¶ added in v0.14.0
func (r *Registrations) AddNode(node *Node) (err error)
func (*Registrations) Close ¶ added in v0.14.0
func (r *Registrations) Close()
func (*Registrations) FetchDocuments ¶ added in v1.0.10
func (*Registrations) FetchNodeDocuments ¶ added in v1.0.10
func (*Registrations) Get ¶ added in v0.14.0
func (r *Registrations) Get(name string, rvs RequestVersions) (registration *Registration, has bool)
func (*Registrations) GetExact ¶ added in v0.14.0
func (r *Registrations) GetExact(name string, id string) (registration *Registration, has bool)
func (*Registrations) GetNodeServices ¶ added in v1.0.10
func (*Registrations) List ¶ added in v1.0.5
func (r *Registrations) List() (values map[string]RegistrationList)
func (*Registrations) ListMembers ¶ added in v1.0.10
func (r *Registrations) ListMembers(ctx context.Context) (members Nodes, err error)
func (*Registrations) MergeNodes ¶ added in v1.0.4
func (r *Registrations) MergeNodes(nodes Nodes) (err error)
func (*Registrations) Refresh ¶ added in v1.0.10
func (r *Registrations) Refresh(ctx context.Context)
func (*Registrations) Remove ¶ added in v0.14.0
func (r *Registrations) Remove(id string)
type Request ¶
type Request interface { Id() (id string) Header() (header RequestHeader) AcceptedVersions() (acceptedVersions RequestVersions) Fn() (service string, fn string) Argument() (argument Argument) Internal() (ok bool) User() (user RequestUser) Trunk() (trunk RequestTrunk) }
func NewRequest ¶
type RequestHeader ¶
func (RequestHeader) Add ¶ added in v0.14.0
func (header RequestHeader) Add(key, value string)
func (RequestHeader) Authorization ¶ added in v0.14.0
func (header RequestHeader) Authorization() (authorization string, has bool)
func (RequestHeader) Clone ¶ added in v1.0.10
func (header RequestHeader) Clone() RequestHeader
func (RequestHeader) Contains ¶
func (header RequestHeader) Contains(key string) (ok bool)
func (RequestHeader) Del ¶ added in v1.0.10
func (header RequestHeader) Del(key string)
func (RequestHeader) DeviceId ¶ added in v0.14.0
func (header RequestHeader) DeviceId() (id string)
func (RequestHeader) DeviceIp ¶ added in v0.14.0
func (header RequestHeader) DeviceIp() (id string)
func (RequestHeader) Empty ¶ added in v1.0.10
func (header RequestHeader) Empty() bool
func (RequestHeader) ForEach ¶ added in v0.14.0
func (header RequestHeader) ForEach(fn func(key string, values []string) (next bool))
func (RequestHeader) Get ¶
func (header RequestHeader) Get(key string) string
func (RequestHeader) Set ¶ added in v0.14.0
func (header RequestHeader) Set(key, value string)
func (RequestHeader) SetAcceptVersions ¶ added in v1.0.10
func (header RequestHeader) SetAcceptVersions(rvs RequestVersions)
func (RequestHeader) SetDeviceId ¶ added in v1.0.10
func (header RequestHeader) SetDeviceId(id string)
func (RequestHeader) SetDeviceIp ¶ added in v1.0.10
func (header RequestHeader) SetDeviceIp(ip string)
func (RequestHeader) Values ¶
func (header RequestHeader) Values(key string) []string
type RequestLimiterConfig ¶ added in v1.0.10
type RequestOption ¶ added in v0.14.0
type RequestOption func(*RequestOptions)
func WithDeviceId ¶ added in v0.14.0
func WithDeviceId(id string) RequestOption
func WithDeviceIp ¶ added in v0.14.0
func WithDeviceIp(ip string) RequestOption
func WithInternalRequest ¶ added in v0.14.0
func WithInternalRequest() RequestOption
func WithRequestHeader ¶ added in v1.0.10
func WithRequestHeader(header transports.Header) RequestOption
func WithRequestId ¶ added in v0.14.0
func WithRequestId(id string) RequestOption
func WithRequestTrunk ¶ added in v0.14.0
func WithRequestTrunk(trunk RequestTrunk) RequestOption
func WithRequestUser ¶ added in v0.14.0
func WithRequestUser(id RequestUserId, attributes *json.Object) RequestOption
func WithRequestVersions ¶ added in v1.0.10
func WithRequestVersions(acceptedVersions RequestVersions) RequestOption
type RequestOptions ¶ added in v0.14.0
type RequestOptions struct {
// contains filtered or unexported fields
}
type RequestTrunk ¶ added in v0.14.0
type RequestUser ¶
type RequestUser interface { json.Marshaler json.Unmarshaler Authenticated() (ok bool) Id() (id RequestUserId) SetId(id RequestUserId) Attributes() (attributes *json.Object) SetAttributes(attributes *json.Object) }
func GetRequestUser ¶ added in v0.13.7
func GetRequestUser(ctx context.Context) (user RequestUser, authenticated bool)
func NewRequestUser ¶
func NewRequestUser(id RequestUserId, attributes *json.Object) (u RequestUser)
type RequestUserId ¶ added in v0.14.0
type RequestUserId string
func (RequestUserId) Exist ¶ added in v1.0.6
func (id RequestUserId) Exist() (ok bool)
func (RequestUserId) Int ¶ added in v0.14.0
func (id RequestUserId) Int() (n int64)
func (RequestUserId) String ¶ added in v0.14.0
func (id RequestUserId) String() string
type RequestVersion ¶ added in v1.0.10
type RequestVersion struct { Pattern string Begin versions.Version End versions.Version Exact bool }
func ParseRequestVersion ¶ added in v1.0.10
func ParseRequestVersion(s string) (rv *RequestVersion, err error)
func (*RequestVersion) Accept ¶ added in v1.0.10
func (rv *RequestVersion) Accept(serviceName string, target versions.Version) (ok bool)
func (*RequestVersion) String ¶ added in v1.0.10
func (rv *RequestVersion) String() string
type RequestVersions ¶ added in v1.0.10
type RequestVersions []*RequestVersion
func AllowAllRequestVersions ¶ added in v1.0.10
func AllowAllRequestVersions() RequestVersions
func ParseRequestVersionFromHeader ¶ added in v1.0.10
func ParseRequestVersionFromHeader(header transports.Header) (rvs RequestVersions, has bool, err error)
func (RequestVersions) Accept ¶ added in v1.0.10
func (rvs RequestVersions) Accept(serviceName string, target versions.Version) (ok bool)
func (RequestVersions) Empty ¶ added in v1.0.10
func (rvs RequestVersions) Empty() (ok bool)
func (RequestVersions) String ¶ added in v1.0.10
func (rvs RequestVersions) String() string
type Runtime ¶ added in v1.0.10
type Runtime struct {
// contains filtered or unexported fields
}
func GetRuntime ¶ added in v1.0.10
func (*Runtime) AppVersion ¶ added in v1.0.10
func (*Runtime) Discovery ¶ added in v1.0.10
func (rt *Runtime) Discovery() EndpointDiscovery
func (*Runtime) SetIntoContext ¶ added in v1.0.10
type RuntimeConfig ¶ added in v0.14.0
type RuntimeConfig struct { MaxWorkers int `json:"maxWorkers"` WorkerMaxIdleSeconds int `json:"workerMaxIdleSeconds"` HandleTimeoutSeconds int `json:"handleTimeoutSeconds"` AutoMaxProcs AutoMaxProcsConfig `json:"autoMaxProcs"` SecretKey string `json:"secretKey"` }
type ServicesSupplier ¶ added in v1.0.10
type ServicesSupplier interface {
Services() (services []Service)
}
type SharedConfig ¶ added in v0.14.0
type SharedConfig struct {}
type Span ¶
type Span struct { Id_ string `json:"id"` Service_ string `json:"service"` Fn_ string `json:"fn"` TracerId_ string `json:"tracerId"` StartAT_ time.Time `json:"startAt"` FinishedAT_ time.Time `json:"finishedAt"` Children_ []*Span `json:"children"` Tags_ map[string]string `json:"tags"` // contains filtered or unexported fields }
func (*Span) AppendChild ¶
func (*Span) FinishedAT ¶
type TLSConfig ¶ added in v0.14.0
type TLSConfig struct { // Kind // ACME // SSC(SELF-SIGN-CERT) // DEFAULT Kind string `json:"kind"` Options json.RawMessage `json:"options"` }
type Tracer ¶
type TransportConfig ¶ added in v1.0.10
type TransportConfig struct { Name string `json:"name"` Port int `json:"port"` Cors *transports.CorsConfig `json:"cors"` TLS *TLSConfig `json:"tls"` Options json.RawMessage `json:"options"` Middlewares json.RawMessage `json:"middlewares"` Handlers json.RawMessage `json:"handlers"` }
func (*TransportConfig) ConvertToTransportsOptions ¶ added in v1.0.10
func (config *TransportConfig) ConvertToTransportsOptions(log logs.Logger, handler transports.Handler) (options transports.Options, err error)
func (*TransportConfig) HandlersConfig ¶ added in v1.0.10
func (config *TransportConfig) HandlersConfig() (conf configures.Config, err error)
func (*TransportConfig) MiddlewaresConfig ¶ added in v1.0.10
func (config *TransportConfig) MiddlewaresConfig() (conf configures.Config, err error)
type TransportHandler ¶ added in v1.0.10
type TransportHandler interface { Name() (name string) Build(options TransportHandlerOptions) (err error) Accept(r *transports.Request) (ok bool) transports.Handler Close() (err error) }
type TransportHandlerOptions ¶ added in v1.0.10
type TransportHandlerOptions struct { AppId string AppName string AppVersion versions.Version AppStatus *Status Log logs.Logger Config configures.Config Discovery EndpointDiscovery }
type TransportMiddleware ¶ added in v1.0.10
type TransportMiddleware interface { Name() (name string) Build(options TransportMiddlewareOptions) (err error) Handler(next transports.Handler) transports.Handler Close() (err error) }
func CacheControlMiddleware ¶ added in v1.0.10
func CacheControlMiddleware() TransportMiddleware
func CustomizeRateLimitMiddleware ¶ added in v1.0.10
func CustomizeRateLimitMiddleware(counter RateLimitCounter) TransportMiddleware
func RateLimitMiddleware ¶ added in v1.0.10
func RateLimitMiddleware() TransportMiddleware
func SignatureMiddleware ¶ added in v1.0.10
func SignatureMiddleware() TransportMiddleware
type TransportMiddlewareOptions ¶ added in v1.0.10
type TransportMiddlewareOptions struct { AppId string AppName string AppVersion versions.Version AppStatus *Status Log logs.Logger Config configures.Config Discovery EndpointDiscovery }
type TransportOptions ¶ added in v1.0.10
type TransportOptions struct { Middlewares []TransportMiddleware Handlers []TransportHandler }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.