Documentation ¶
Index ¶
- Constants
- func LevelFilter() *logutils.LevelFilter
- func ValidateLevelFilter(filter *logutils.LevelFilter) bool
- type Agent
- func (a *Agent) Join(addrs []string) (n int, err error)
- func (a *Agent) NotifyLogs(ch chan<- string) []string
- func (a *Agent) Serf() *serf.Serf
- func (a *Agent) Shutdown() error
- func (a *Agent) Start() error
- func (a *Agent) StopLogs(ch chan<- string)
- func (a *Agent) UserEvent(name string, payload []byte) error
- type AgentState
- type AppendSliceValue
- type Command
- type Config
- type EventHandler
- type EventScript
- type EventWriter
- type GatedWriter
- type MockEventHandler
- type RPCClient
- func (c *RPCClient) Close() error
- func (c *RPCClient) Join(addrs []string) (n int, err error)
- func (c *RPCClient) Members() ([]serf.Member, error)
- func (c *RPCClient) Monitor(level logutils.LogLevel, ch chan<- string, done <-chan struct{}) error
- func (c *RPCClient) UserEvent(name string, payload []byte) error
- type RPCMonitorArgs
- type RPCUserEventArgs
- type ScriptEventHandler
Constants ¶
const DefaultBindPort int = 7946
This is the default port that we use for Serf communication
Variables ¶
This section is empty.
Functions ¶
func LevelFilter ¶
func LevelFilter() *logutils.LevelFilter
LevelFilter returns a LevelFilter that is configured with the log levels that we use.
func ValidateLevelFilter ¶
func ValidateLevelFilter(filter *logutils.LevelFilter) bool
ValidateLevelFilter verifies that the log levels within the filter are valid.
Types ¶
type Agent ¶
type Agent struct { // EventHandler is what is invoked when an event occurs. If this // isn't set, then events aren't handled in any special way. EventHandler EventHandler // LogOutput is where log messages are written to for the Agent, // Serf, and the underlying Memberlist. LogOutput io.Writer // RPCAddr is the address to bind the RPC listener to. RPCAddr string // SerfConfig is the configuration of Serf to use. Some settings // in here may be overriden by the agent. SerfConfig *serf.Config // contains filtered or unexported fields }
Agent starts and manages a Serf instance, adding some niceties on top of Serf such as storing logs that you can later retrieve, invoking and EventHandler when events occur, and putting an RPC layer in front so that you can query and control the Serf instance remotely.
func (*Agent) NotifyLogs ¶
NotifyLogs causes the agent to begin sending log events to the given channel. The return value is a buffer of past events up to a point.
All NotifyLogs calls should be paired with a StopLogs call.
func (*Agent) Start ¶
Start starts the agent, kicking off any goroutines to handle various aspects of the agent.
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 { ShutdownCh <-chan struct{} // contains filtered or unexported fields }
Command is a Command implementation that runs a Serf 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.
type Config ¶
type Config struct { // All the configurations in this section are identical to their // Serf counterparts. See the documentation for Serf.Config for // more info. NodeName string `mapstructure:"node_name"` Role string `mapstructure:"role"` // BindAddr is the address that the Serf agent's communication ports // will bind to. Serf will use this address to bind to for both TCP // and UDP connections. If no port is present in the address, the default // port will be used. BindAddr string `mapstructure:"bind_addr"` // RPCAddr is the address and port to listen on for the agent's RPC // interface. RPCAddr string `mapstructure:"rpc_addr"` // EventHandlers is a list of event handlers that will be invoked. EventHandlers []string `mapstructure:"event_handlers"` }
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 (*Config) BindAddrParts ¶
BindAddrParts returns the parts of the BindAddr that should be used to configure Serf.
func (*Config) EventScripts ¶
func (c *Config) EventScripts() ([]EventScript, error)
EventScripts returns the list of EventScripts associated with this configuration and specified by the "event_handlers" configuration.
type EventHandler ¶
EventHandler is a handler that does things when events happen.
type EventScript ¶
EventScript is a single event script that will be executed in the case of an event, and is configured from the command-line or from a configuration file.
func ParseEventScript ¶
func ParseEventScript(v string) ([]EventScript, error)
ParseEventScript takes a string in the format of "type=script" and parses it into an EventScript struct, if it can.
func (*EventScript) Invoke ¶
func (s *EventScript) Invoke(e serf.Event) bool
Invoke tests whether or not this event script should be invoked for the given Serf event.
func (*EventScript) String ¶
func (s *EventScript) String() string
func (*EventScript) Valid ¶
func (s *EventScript) Valid() bool
Valid checks if this is a valid agent event script.
type EventWriter ¶
type EventWriter struct {
Agent *Agent
}
EventWriter is an io.Writer that writes all of its output to the event log of an agent.
type GatedWriter ¶
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.
type MockEventHandler ¶
MockEventHandler is an EventHandler implementation that can be used for tests.
func (*MockEventHandler) HandleEvent ¶
type RPCClient ¶
RPCClient is the RPC client to make requests to the agent RPC.
type RPCMonitorArgs ¶
RPCMonitorArgs are the args for the Monitor RPC call.
type RPCUserEventArgs ¶
RPCUserEventArgs are the args for the user event RPC call.
type ScriptEventHandler ¶
type ScriptEventHandler struct { Self serf.Member Scripts []EventScript }
ScriptEventHandler invokes scripts for the events that it receives.