agent

package
v0.0.0-...-8fafcef Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2014 License: MPL-2.0 Imports: 24 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MinIPCVersion = 1
	MaxIPCVersion = 1
)

Protocol versions

Variables

View Source
var DefaultConfig = &Config{
	LogLevel: "INFO",
	RPCAddr:  "127.0.0.1:6673",
}

DefaultConfig contains the defaults for configurations.

Functions

func LevelFilter

func LevelFilter() *logutils.LevelFilter

LevelFilter returns a LevelFilter that is configured with the log levels that we use.

func NewLogWriter

func NewLogWriter(buf int) *logWriter

NewLogWriter creates a logWriter with the given buffer capacity

func ValidateLevelFilter

func ValidateLevelFilter(minLevel logutils.LogLevel, filter *logutils.LevelFilter) bool

ValidateLevelFilter verifies that the log levels within the filter are valid.

Types

type Agent

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

Agent starts and manages the Watchdog instance.

func NewAgent

func NewAgent(config *Config, logOutput io.Writer) *Agent

func (*Agent) RegisterProcess

func (a *Agent) RegisterProcess(configPath string) (*process.Process, error)

RegisterProcess takes a configuration file and registers a new process

func (*Agent) Shutdown

func (a *Agent) Shutdown() error

func (*Agent) ShutdownCh

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

ShutdownCh returns a channel that can be selected to wait for the agent to perform a shutdown.

func (*Agent) Start

func (a *Agent) Start() error

func (*Agent) StartProcess

func (a *Agent) StartProcess(name string) (*process.Process, error)

StartProcess starts a process by name

type AgentIPC

type AgentIPC struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewAgentIPC

func NewAgentIPC(agent *Agent, listener net.Listener,
	logOutput io.Writer, logWriter *logWriter) *AgentIPC

NewAgentIPC is used to create a new Agent IPC handler

func (*AgentIPC) Shutdown

func (i *AgentIPC) Shutdown()

Shutdown is used to shutdown the IPC layer

type AppendSliceValue

type AppendSliceValue []string

AppendSliceValue implements the flag.Value interface and allows multiple calls to the same variable to append a list.

func (*AppendSliceValue) Set

func (s *AppendSliceValue) Set(value string) error

func (*AppendSliceValue) String

func (s *AppendSliceValue) String() string

type Command

type Command struct {
	Ui         cli.Ui
	ShutdownCh <-chan struct{}
	// contains filtered or unexported fields
}

Command is a Command implementation that runs a Watchdog agent. The command will not end unless a shutdown message is sent on the ShutdownCh. If two messages are sent on the ShutdownCh it will forcibly exit.

func (*Command) Help

func (c *Command) Help() string

func (*Command) Run

func (c *Command) Run(args []string) int

func (*Command) Synopsis

func (c *Command) Synopsis() string

type Config

type Config struct {

	// LogLevel is the level of the logs to output.
	// This can be updated during a reload.
	LogLevel string `mapstructure:"log_level"`

	// RPCAddr is the address and port to listen on for the agent's RPC
	// interface.
	RPCAddr string `mapstructure:"rpc_addr"`
}

Config is the configuration that can be set for an Agent. Some of these configurations are exposed as command-line flags to `serf agent`, whereas many of the more advanced configurations can only be set by creating a configuration file.

func DecodeConfigFromJSON

func DecodeConfigFromJSON(r io.Reader) (*Config, error)

DecodeConfigFromJSON decodes a JSON config

func DecodeConfigFromTOML

func DecodeConfigFromTOML(r io.Reader) (*Config, error)

DecodeConfigFromTOML decodes a TOML config

func MergeConfig

func MergeConfig(a, b *Config) *Config

MergeConfig merges two configurations together to make a single new configuration.

func ReadConfigPaths

func ReadConfigPaths(paths []string) (*Config, error)

ReadConfigPaths reads the paths in the given order to load configurations. The paths can be to files or directories. If the path is a directory, we read one directory deep and read any files ending in ".json" as configuration files.

type GatedWriter

type GatedWriter struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

GatedWriter is an io.Writer implementation that buffers all of its data into an internal buffer until it is told to let data through.

func (*GatedWriter) Flush

func (w *GatedWriter) Flush()

Flush tells the GatedWriter to flush any buffered data and to stop buffering.

func (*GatedWriter) Write

func (w *GatedWriter) Write(p []byte) (n int, err error)

type IPCClient

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

func (*IPCClient) Send

func (c *IPCClient) Send(header *responseHeader, obj interface{}) error

send is used to send an object using the MsgPack encoding. send is serialized to prevent write overlaps, while properly buffering.

func (*IPCClient) String

func (c *IPCClient) String() string

type LogHandler

type LogHandler interface {
	HandleLog(string)
}

LogHandler interface is used for clients that want to subscribe to logs, for example to stream them over an IPC mechanism

type RPCClient

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

RPCClient is the RPC client to make requests to the agent RPC.

func NewRPCClient

func NewRPCClient(addr string) (*RPCClient, error)

NewRPCClient is used to create a new RPC client given the address. This will properly dial, handshake, and start listening

func (*RPCClient) Close

func (c *RPCClient) Close() error

Close is used to free any resources associated with the client

func (*RPCClient) Register

func (c *RPCClient) Register(configPaths []string, watchPaths, startOnLoad bool) ([]string, error)

Register is used to instruct watchdog to monitor a new process. It returns a list of process names the were successfully added.

func (*RPCClient) Start

func (r *RPCClient) Start(names ...string) ([]int, error)

Jump to

Keyboard shortcuts

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