Documentation ¶
Index ¶
- type Actor
- type Balancer
- type BalancerStrategy
- type Client
- func (x *Client) Ask(ctx context.Context, actor *Actor, message proto.Message, ...) (reply proto.Message, err error)
- func (x *Client) Close()
- func (x *Client) Kinds(ctx context.Context) ([]string, error)
- func (x *Client) ReSpawn(ctx context.Context, actor *Actor) (err error)
- func (x *Client) Spawn(ctx context.Context, actor *Actor) (err error)
- func (x *Client) SpawnWithBalancer(ctx context.Context, actor *Actor, strategy BalancerStrategy) (err error)
- func (x *Client) Stop(ctx context.Context, actor *Actor) error
- func (x *Client) Tell(ctx context.Context, actor *Actor, message proto.Message) error
- func (x *Client) Whereis(ctx context.Context, actor *Actor) (*address.Address, error)
- type LeastLoad
- type Node
- func (n *Node) Address() string
- func (n *Node) Free()
- func (n *Node) HTTPClient() *nethttp.Client
- func (n *Node) HTTPEndPoint() string
- func (n *Node) HostAndPort() (string, int)
- func (n *Node) Remoting() *actors.Remoting
- func (n *Node) SetWeight(weight float64)
- func (n *Node) Validate() error
- func (n *Node) Weight() float64
- type NodeOption
- type Option
- type OptionFunc
- type Random
- type RoundRobin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Actor ¶
type Actor struct {
// contains filtered or unexported fields
}
Actor defines a given actor name and kind
type Balancer ¶
type Balancer interface { // Set sets the balancer nodes pool Set(nodes ...*Node) // Next returns the appropriate weight-balanced node to use Next() *Node }
Balancer helps locate the right node to channel Client request to
type BalancerStrategy ¶
type BalancerStrategy int
BalancerStrategy defines the Client weight balancer strategy
const ( // RoundRobinStrategy uses the round-robin algorithm to determine the appropriate node RoundRobinStrategy BalancerStrategy = iota // RandomStrategy uses the random algorithm to determine the appropriate node RandomStrategy // LeastLoadStrategy choses among a pool of nodes the node that has the less weight // at the time of the execution LeastLoadStrategy )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client connects to af Go-Akt nodes. This client can only be used when remoting is enabled on the various nodes. The client is only used against a Go-Akt cluster
func New ¶
New creates an instance of Client. The provided nodes are the cluster nodes. A node is the form of host:port where host and port represents the remoting host and remoting port of the nodes. The nodes list will be load balanced based upon the load-balancing strategy defined by default round-robin will be used. An instance of the Client can be reused and it is thread safe.
func (*Client) Ask ¶
func (x *Client) Ask(ctx context.Context, actor *Actor, message proto.Message, timeout time.Duration) (reply proto.Message, err error)
Ask sends a message to a given actor provided the actor name and expects a response. If the given actor does not exist it will be created automatically when Client mode is enabled. This will block until a response is received or timed out.
func (*Client) SpawnWithBalancer ¶ added in v2.2.2
func (x *Client) SpawnWithBalancer(ctx context.Context, actor *Actor, strategy BalancerStrategy) (err error)
SpawnWithBalancer creates an actor provided the actor name and the balancer strategy
type LeastLoad ¶
type LeastLoad struct {
// contains filtered or unexported fields
}
LeastLoad uses the LeastLoadStrategy to pick the next available node in the pool
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents the node in the cluster
func NewNode ¶
func NewNode(address string, opts ...NodeOption) *Node
NewNode creates an instance of Node
func (*Node) Free ¶ added in v2.8.0
func (n *Node) Free()
Free closes the underlying http client connection of the given node
func (*Node) HTTPClient ¶ added in v2.8.0
HTTPClient returns the underlying http client for the given node
func (*Node) HTTPEndPoint ¶ added in v2.8.0
HTTPEndPoint returns the node remote endpoint
func (*Node) HostAndPort ¶ added in v2.8.0
HostAndPort returns the node host and port
type NodeOption ¶ added in v2.8.0
type NodeOption func(*Node)
func WithWeight ¶ added in v2.8.0
func WithWeight(weight float64) NodeOption
WithWeight set the node weight
type Option ¶
type Option interface { // Apply sets the Option value of a config. Apply(cl *Client) }
Option is the interface that applies a configuration option.
func WithBalancerStrategy ¶
func WithBalancerStrategy(strategy BalancerStrategy) Option
WithBalancerStrategy sets the Client weight balancer strategy
func WithRefresh ¶
WithRefresh sets a refresh interval. This help check the nodes state time to time. This help remove dead nodes from the pool
type OptionFunc ¶
type OptionFunc func(*Client)
OptionFunc implements the Option interface.
func (OptionFunc) Apply ¶
func (f OptionFunc) Apply(c *Client)
type Random ¶
type Random struct {
// contains filtered or unexported fields
}
Random helps pick a node at random
type RoundRobin ¶
type RoundRobin struct {
// contains filtered or unexported fields
}
RoundRobin implements the round-robin algorithm to pick a particular nodes in the cluster
func NewRoundRobin ¶
func NewRoundRobin() *RoundRobin
NewRoundRobin creates an instance of RoundRobin