clusters

package
v1.2.85 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: Apache-2.0 Imports: 38 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Add    = NodeEventKind(1)
	Remove = NodeEventKind(2)
)

Variables

View Source
var (
	ErrTooEarly               = errors.TooEarly("fns: service is not ready, try later again")
	ErrUnavailable            = errors.Unavailable("fns: service is closed")
	ErrDeviceId               = errors.Warning("fns: device id was required")
	ErrInvalidPath            = errors.Warning("fns: invalid path")
	ErrInvalidBody            = errors.Warning("fns: invalid body")
	ErrInvalidRequestVersions = errors.Warning("fns: invalid request versions")
	ErrTooMayRequest          = errors.TooMayRequest("fns: too may request, try again later")
	ErrSignatureLost          = errors.New(488, "***SIGNATURE LOST***", "X-Fns-Signature was required")
	ErrSignatureUnverified    = errors.New(458, "***SIGNATURE INVALID***", "X-Fns-Signature was invalid")
)

Functions

func New

func New(options Options) (manager services.EndpointsManager, shared shareds.Shared, barrier barriers.Barrier, handlers []transports.MuxHandler, err error)

func NewInternalHandler

func NewInternalHandler(local services.Endpoints, signature signatures.Signature) transports.MuxHandler

func NewSignature

func NewSignature(secret string) signatures.Signature

func RegisterCluster

func RegisterCluster(name string, cluster Cluster)

func RegisterHostRetriever

func RegisterHostRetriever(name string, fn HostRetriever)

Types

type Cluster

type Cluster interface {
	Construct(options ClusterOptions) (err error)
	AddService(service Service)
	Join(ctx context.Context) (err error)
	Leave(ctx context.Context) (err error)
	NodeEvents() (events <-chan NodeEvent)
	Shared() (shared shareds.Shared)
	Barrier() (barrier barriers.Barrier)
}

func NewDevelopment

func NewDevelopment(dialer transports.Dialer, signature signatures.Signature) Cluster

type ClusterBuilderOptions

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

type ClusterEndpointsManager

type ClusterEndpointsManager interface {
	services.EndpointsManager
	FnAddress(ctx context.Context, endpoint []byte, fnName []byte, options ...services.EndpointGetOption) (address string, internal bool, has bool)
}

func NewManager

func NewManager(id string, version versions.Version, address string, cluster Cluster, local services.EndpointsManager, worker workers.Workers, log logs.Logger, dialer transports.Dialer, signature signatures.Signature) ClusterEndpointsManager

type ClusterOptions

type ClusterOptions struct {
	Log     logs.Logger
	Config  configures.Config
	Id      string
	Version versions.Version
	Address string
}

type Config

type Config struct {
	Secret        string          `json:"secret"`
	HostRetriever string          `json:"hostRetriever"`
	Name          string          `json:"name"`
	Proxy         bool            `json:"proxy"`
	Option        json.RawMessage `json:"option"`
}

type Development

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

func (*Development) AddService

func (cluster *Development) AddService(_ Service)

func (*Development) Barrier added in v1.2.0

func (cluster *Development) Barrier() (barrier barriers.Barrier)

func (*Development) Client added in v1.2.80

func (cluster *Development) Client() transports.Client

func (*Development) Construct

func (cluster *Development) Construct(options ClusterOptions) (err error)

func (*Development) Join

func (cluster *Development) Join(ctx context.Context) (err error)

func (*Development) Leave

func (cluster *Development) Leave(_ context.Context) (err error)

func (*Development) NodeEvents

func (cluster *Development) NodeEvents() (events <-chan NodeEvent)

func (*Development) Shared

func (cluster *Development) Shared() (shared shareds.Shared)

type DevelopmentConfig

type DevelopmentConfig struct {
	ProxyAddr string `json:"proxyAddr"`
}

type Endpoint

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

func NewEndpoint

func NewEndpoint(log logs.Logger, address string, id string, version versions.Version, name string, internal bool, document documents.Endpoint, client transports.Client, signature signatures.Signature) (endpoint *Endpoint)

func (*Endpoint) AddFn

func (endpoint *Endpoint) AddFn(name string, internal bool, readonly bool)

func (*Endpoint) Address

func (endpoint *Endpoint) Address() string

func (*Endpoint) Document

func (endpoint *Endpoint) Document() documents.Endpoint

func (*Endpoint) Functions

func (endpoint *Endpoint) Functions() services.Fns

func (*Endpoint) Id added in v1.2.32

func (endpoint *Endpoint) Id() string

func (*Endpoint) Info

func (endpoint *Endpoint) Info() services.EndpointInfo

func (*Endpoint) Internal

func (endpoint *Endpoint) Internal() bool

func (*Endpoint) IsHealth added in v1.2.0

func (endpoint *Endpoint) IsHealth() bool

func (*Endpoint) Name

func (endpoint *Endpoint) Name() string

func (*Endpoint) Running

func (endpoint *Endpoint) Running() bool

func (*Endpoint) Shutdown

func (endpoint *Endpoint) Shutdown(_ context.Context)

type Endpoints

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

func (*Endpoints) Add added in v1.2.32

func (endpoints *Endpoints) Add(ep *Endpoint)

func (*Endpoints) Get added in v1.2.32

func (endpoints *Endpoints) Get(id []byte) *Endpoint

func (*Endpoints) Infos added in v1.2.32

func (endpoints *Endpoints) Infos() (v services.EndpointInfos)

func (*Endpoints) MaxOne added in v1.2.32

func (endpoints *Endpoints) MaxOne() (ep *Endpoint)

func (*Endpoints) Range added in v1.2.32

func (endpoints *Endpoints) Range(interval versions.Interval) *Endpoint

func (*Endpoints) Remove added in v1.2.32

func (endpoints *Endpoints) Remove(id []byte)

type Entry

type Entry struct {
	Key   []byte `json:"key" avro:"key"`
	Value []byte `json:"value" avro:"value"`
}

type Fn

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

func (*Fn) Enable

func (fn *Fn) Enable() bool

func (*Fn) Handle

func (fn *Fn) Handle(ctx services.Request) (v interface{}, err error)

func (*Fn) Internal

func (fn *Fn) Internal() bool

func (*Fn) Name

func (fn *Fn) Name() string

func (*Fn) Readonly

func (fn *Fn) Readonly() bool

type HostRetriever

type HostRetriever func() (host string, err error)

type InternalHandler

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

func (*InternalHandler) Construct

func (handler *InternalHandler) Construct(_ transports.MuxHandlerOptions) error

func (*InternalHandler) Handle

func (*InternalHandler) Match

func (handler *InternalHandler) Match(_ context.Context, method []byte, path []byte, header transports.Header) bool

func (*InternalHandler) Name

func (handler *InternalHandler) Name() string

type Manager

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

func (*Manager) Add

func (manager *Manager) Add(service services.Service) (err error)

func (*Manager) FnAddress added in v1.2.21

func (manager *Manager) FnAddress(ctx context.Context, endpoint []byte, fnName []byte, options ...services.EndpointGetOption) (address string, internal bool, has bool)

func (*Manager) Get

func (manager *Manager) Get(ctx context.Context, name []byte, options ...services.EndpointGetOption) (endpoint services.Endpoint, has bool)

func (*Manager) Info

func (manager *Manager) Info() (infos services.EndpointInfos)

func (*Manager) Listen

func (manager *Manager) Listen(ctx context.Context) (err error)

func (*Manager) Request

func (manager *Manager) Request(ctx context.Context, name []byte, fn []byte, param interface{}, options ...services.RequestOption) (response services.Response, err error)

func (*Manager) RequestAsync added in v1.2.34

func (manager *Manager) RequestAsync(ctx context.Context, name []byte, fn []byte, param any, options ...services.RequestOption) (future futures.Future, err error)

func (*Manager) Shutdown

func (manager *Manager) Shutdown(ctx context.Context)

type Node

type Node struct {
	Id       string           `json:"id"`
	Version  versions.Version `json:"version"`
	Address  string           `json:"address"`
	Services []Service        `json:"services"`
}

type NodeEvent

type NodeEvent struct {
	Kind NodeEventKind
	Node Node
}

type NodeEventKind

type NodeEventKind int

func (NodeEventKind) String added in v1.2.0

func (kind NodeEventKind) String() string

type Nodes

type Nodes []Node

func MapEndpointInfosToNodes

func MapEndpointInfosToNodes(infos services.EndpointInfos) (nodes Nodes)

func (Nodes) Add

func (nodes Nodes) Add(node Node) Nodes

func (Nodes) Difference

func (nodes Nodes) Difference(olds Nodes) (events []NodeEvent)

func (Nodes) Len

func (nodes Nodes) Len() int

func (Nodes) Less

func (nodes Nodes) Less(i, j int) bool

func (Nodes) Remove

func (nodes Nodes) Remove(node Node) Nodes

func (Nodes) Swap

func (nodes Nodes) Swap(i, j int)

type Options

type Options struct {
	Id      string
	Version versions.Version
	Port    int
	Log     logs.Logger
	Worker  workers.Workers
	Local   services.EndpointsManager
	Dialer  transports.Dialer
	Config  Config
}

type Registration

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

func (*Registration) Add

func (r *Registration) Add(endpoint *Endpoint)

func (*Registration) Get

func (r *Registration) Get(name []byte, id []byte) *Endpoint

func (*Registration) Infos added in v1.2.32

func (r *Registration) Infos() (v services.EndpointInfos)

func (*Registration) MaxOne

func (r *Registration) MaxOne(name []byte) *Endpoint

func (*Registration) Range

func (r *Registration) Range(name []byte, interval versions.Interval) *Endpoint

func (*Registration) Remove

func (r *Registration) Remove(name string, id string)

type RequestBody

type RequestBody struct {
	ContextUserValues []Entry `json:"contextUserValues" avro:"contextUserValues"`
	Params            []byte  `json:"params" avro:"params"`
}

type ResponseBody

type ResponseBody struct {
	Succeed     bool    `json:"succeed" avro:"succeed"`
	Data        []byte  `json:"data" avro:"data"`
	Attachments []Entry `json:"attachments" avro:"attachments"`
}

func (ResponseBody) GetSpan added in v1.2.0

func (rsp ResponseBody) GetSpan() (v *tracings.Span, has bool)

type Service

type Service struct {
	Name        string           `json:"name"`
	Internal    bool             `json:"internal"`
	Functions   services.FnInfos `json:"functions"`
	DocumentRaw []byte           `json:"document"`
}

func NewService

func NewService(name string, internal bool, functions services.FnInfos, document documents.Endpoint) (service Service, err error)

func (Service) Document

func (service Service) Document() (document documents.Endpoint, err error)

type SortedVersionEndpoints added in v1.2.32

type SortedVersionEndpoints []*VersionEndpoints

func (SortedVersionEndpoints) Add added in v1.2.32

func (SortedVersionEndpoints) Get added in v1.2.32

func (SortedVersionEndpoints) Len added in v1.2.32

func (list SortedVersionEndpoints) Len() int

func (SortedVersionEndpoints) Less added in v1.2.32

func (list SortedVersionEndpoints) Less(i, j int) bool

func (SortedVersionEndpoints) Swap added in v1.2.32

func (list SortedVersionEndpoints) Swap(i, j int)

type VersionEndpoints added in v1.2.32

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

func (*VersionEndpoints) Add added in v1.2.32

func (endpoints *VersionEndpoints) Add(ep *Endpoint)

func (*VersionEndpoints) Get added in v1.2.32

func (endpoints *VersionEndpoints) Get(id []byte) (ep *Endpoint)

func (*VersionEndpoints) Next added in v1.2.32

func (endpoints *VersionEndpoints) Next() (ep *Endpoint)

func (*VersionEndpoints) Remove added in v1.2.32

func (endpoints *VersionEndpoints) Remove(id []byte) (ok bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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