agent

package
v0.0.0-...-f0983eb Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2016 License: Apache-2.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAgentClosed is returned by agent methods after the agent has been
	// fully closed.
	ErrAgentClosed = errors.New("agent: closed")
)

Functions

This section is empty.

Types

type Agent

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

Agent implements the primary node functionality for a member of a swarm cluster. The primary functionality id to run and report on the status of tasks assigned to the node.

func New

func New(config *Config) (*Agent, error)

New returns a new agent, ready for task dispatch.

func (*Agent) Err

func (a *Agent) Err(ctx context.Context) error

Err returns the error that caused the agent to shutdown or nil. Err blocks until the agent is fully shutdown.

func (*Agent) Ready

func (a *Agent) Ready() <-chan struct{}

Ready returns a channel that will be closed when agent first becomes ready.

func (*Agent) Start

func (a *Agent) Start(ctx context.Context) error

Start begins execution of the agent in the provided context, if not already started.

func (*Agent) Stop

func (a *Agent) Stop(ctx context.Context) error

Stop shuts down the agent, blocking until full shutdown. If the agent is not started, Stop will block until Started.

type Config

type Config struct {
	// Hostname the name of host for agent instance.
	Hostname string

	// Managers provides the manager backend used by the agent. It will be
	// updated with managers weights as observed by the agent.
	Managers picker.Remotes

	// Executor specifies the executor to use for the agent.
	Executor exec.Executor

	// Conn specifies the client connection Agent will use
	Conn *grpc.ClientConn

	// NotifyRoleChange channel receives new roles from session messages.
	NotifyRoleChange chan<- api.NodeRole
}

Config provides values for an Agent.

type Node

type Node struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Node implements the primary node functionality for a member of a swarm cluster. Node handles workloads and may also run as a manager.

func NewNode

func NewNode(c *NodeConfig) (*Node, error)

NewNode returns new Node instance.

func (*Node) Agent

func (n *Node) Agent() *Agent

Agent returns agent instance started by node. May be nil.

func (*Node) Err

func (n *Node) Err(ctx context.Context) error

Err returns the error that caused the node to shutdown or nil. Err blocks until the node has fully shut down.

func (*Node) ListenControlSocket

func (n *Node) ListenControlSocket(ctx context.Context) <-chan *grpc.ClientConn

ListenControlSocket listens changes of a connection for managing the cluster control api

func (*Node) Manager

func (n *Node) Manager() *manager.Manager

Manager return manager instance started by node. May be nil.

func (*Node) NodeID

func (n *Node) NodeID() string

NodeID returns current node's ID. May be empty if not set.

func (*Node) Ready

func (n *Node) Ready(ctx context.Context) <-chan struct{}

Ready returns a channel that is closed after node's initialization has completes for the first time.

func (*Node) Remotes

func (n *Node) Remotes() []api.Peer

Remotes returns a list of known peers known to node.

func (*Node) Start

func (n *Node) Start(ctx context.Context) error

Start starts a node instance.

func (*Node) Stop

func (n *Node) Stop(ctx context.Context) error

Stop stops node execution

type NodeConfig

type NodeConfig struct {
	// Hostname the name of host for agent instance.
	Hostname string

	// JoinAddrs specifies node that should be used for the initial connection to
	// other manager in cluster. This should be only one address and optional,
	// the actual remotes come from the stored state.
	JoinAddr string

	// StateDir specifies the directory the node uses to keep the state of the
	// remote managers and certificates.
	StateDir string

	// CAHash to be used on the first certificate request.
	CAHash string

	// Secret to be used on the first certificate request.
	Secret string

	// ForceNewCluster creates a new cluster from current raft state.
	ForceNewCluster bool

	// ListenControlAPI specifies address the control API should listen on.
	ListenControlAPI string

	// ListenRemoteAPI specifies the address for the remote API that agents
	// and raft members connect to.
	ListenRemoteAPI string

	// Executor specifies the executor to use for the agent.
	Executor exec.Executor

	// ElectionTick defines the amount of ticks needed without
	// leader to trigger a new election
	ElectionTick uint32

	// HeartbeatTick defines the amount of ticks between each
	// heartbeat sent to other members for health-check purposes
	HeartbeatTick uint32

	// todo: temporary to bypass promotion not working yet
	IsManager bool
}

NodeConfig provides values for a Node.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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