Documentation

Overview

    Package proc manages etcd processes.

    Index

    Constants

    This section is empty.

    Variables

    This section is empty.

    Functions

    func CombineFlags

    func CombineFlags(remote bool, cs ...*Flags) error

      CombineFlags combine flags under a same cluster.

      Types

      type Cluster

      type Cluster interface {
      	// Write writes messages to a Node process.
      	Write(name, msg string, streamIDs ...string) error
      
      	// SharedStream returns a shared stream.
      	SharedStream() chan string
      
      	// Stream returns the channel for streaming logs.
      	Stream(streamID string) chan string
      
      	// Start starts Node process.
      	Start(name string) error
      
      	// Restart restarts Node process.
      	Restart(name string) error
      
      	// Revive restarts all Nodes in case no Node is up for a certain period of
      	// time.
      	Revive() error
      
      	// Terminate kills the Node process.
      	Terminate(name string) error
      
      	// Clean cleans up the resources from the Node. This must be called
      	// after Terminate.
      	Clean(name string) error
      
      	// Bootstrap starts all Node processes.
      	Bootstrap() error
      
      	// Shutdown terminates and cleans all Nodes.
      	Shutdown() error
      
      	// Endpoints returns all endpoints for clients and a map of name and endpoint, vice versa.
      	Endpoints() ([]string, map[string]string, map[string]string)
      
      	// Leader returns the name of the leader.
      	Leader() (string, error)
      
      	// Status returns all endpoints and status of the cluster.
      	Status() (map[string]ServerStatus, error)
      
      	// Put puts key-value to the cluster. If the name is not specified, it
      	// sends request to a random node.
      	Put(name, key, value string, streamIDs ...string) (time.Duration, error)
      
      	// Get get the value from the key. If the name is not specified,
      	// it gets from a random node.
      	Get(name, key string, prefix bool, streamIDs ...string) ([]string, time.Duration, error)
      
      	// Delete deletes the key.
      	Delete(ame, key string, prefix bool, streamIDs ...string) (int64, time.Duration, error)
      
      	// Stress stresses the cluster. If the name is not specified, it stresses
      	// random nodes.
      	Stress(name string, stressN int, streamIDs ...string) (time.Duration, error)
      }

        Cluster controls a set of Nodes.

        func NewCluster

        func NewCluster(opt NodeType, programPath string, fs []*Flags, opts ...OpOption) (Cluster, error)

          NewCluster creates Cluster with generated flags.

          type Flags

          type Flags struct {
          	Name    string `flag:"name"`
          	DataDir string `flag:"data-dir"`
          
          	ListenClientURLs    map[string]struct{} `flag:"listen-client-urls"`
          	AdvertiseClientURLs map[string]struct{} `flag:"advertise-client-urls"`
          	ListenPeerURLs      map[string]struct{} `flag:"listen-peer-urls"`
          	AdvertisePeerURLs   map[string]struct{} `flag:"initial-advertise-peer-urls"`
          
          	InitialCluster      map[string]string `flag:"initial-cluster"`
          	InitialClusterToken string            `flag:"initial-cluster-token"`
          	InitialClusterState string            `flag:"initial-cluster-state"`
          
          	ClientAutoTLS bool `flag:"auto-tls"`
          	PeerAutoTLS   bool `flag:"peer-auto-tls"`
          }

            Flags is a set of etcd flags.

            func GenerateFlags

            func GenerateFlags(name, host string, remote bool) (*Flags, error)

              GenerateFlags returns generated default flags.

              func (*Flags) IsValid

              func (f *Flags) IsValid() (bool, error)

              func (*Flags) Pairs

              func (f *Flags) Pairs() ([][]string, error)

              func (*Flags) String

              func (f *Flags) String() (string, error)

              func (*Flags) StringSlice

              func (f *Flags) StringSlice() ([]string, error)

              type Node

              type Node interface {
              	// Endpoint returns the gRPC endpoint.
              	Endpoint() string
              
              	// StatusEndpoint returns the v2 status endpoint.
              	StatusEndpoint() string
              
              	// IsActive returns true if the Node is running(active).
              	IsActive() bool
              
              	// Start starts Node process.
              	Start() error
              
              	// Restart restarts Node process.
              	Restart() error
              
              	// Terminate kills the Node process.
              	Terminate() error
              
              	// Clean cleans up the resources from the Node. This must be called
              	// after Terminate.
              	Clean() error
              
              	// TLS returns the *tls.Config of the Node.
              	TLS() *tls.Config
              }

                Node contains node operations.

                type NodeType

                type NodeType int
                const (
                	WebLocal NodeType = iota
                	WebRemote
                )

                type NodeWebLocal

                type NodeWebLocal struct {
                	ProgramPath string
                	Flags       *Flags
                
                	TLSCertPath string
                	TLSKeyPath  string
                	TLSConfig   *tls.Config
                
                	PID int
                	// contains filtered or unexported fields
                }

                  NodeWebLocal represents an etcd node in local web host.

                  func (*NodeWebLocal) Clean

                  func (nd *NodeWebLocal) Clean() error

                  func (*NodeWebLocal) Endpoint

                  func (nd *NodeWebLocal) Endpoint() string

                  func (*NodeWebLocal) IsActive

                  func (nd *NodeWebLocal) IsActive() bool

                  func (*NodeWebLocal) Restart

                  func (nd *NodeWebLocal) Restart() error

                  func (*NodeWebLocal) Start

                  func (nd *NodeWebLocal) Start() error

                  func (*NodeWebLocal) StatusEndpoint

                  func (nd *NodeWebLocal) StatusEndpoint() string

                  func (*NodeWebLocal) TLS

                  func (nd *NodeWebLocal) TLS() *tls.Config

                  func (*NodeWebLocal) Terminate

                  func (nd *NodeWebLocal) Terminate() error

                  func (*NodeWebLocal) Write

                  func (nd *NodeWebLocal) Write(p []byte) (int, error)

                  type NodeWebRemoteClient

                  type NodeWebRemoteClient struct {
                  	Flags *Flags
                  
                  	TLSCertPath string
                  	TLSKeyPath  string
                  	TLSConfig   *tls.Config
                  
                  	Agent client.Agent
                  	// contains filtered or unexported fields
                  }

                  func (*NodeWebRemoteClient) Clean

                  func (nd *NodeWebRemoteClient) Clean() error

                  func (*NodeWebRemoteClient) Endpoint

                  func (nd *NodeWebRemoteClient) Endpoint() string

                  func (*NodeWebRemoteClient) IsActive

                  func (nd *NodeWebRemoteClient) IsActive() bool

                  func (*NodeWebRemoteClient) Restart

                  func (nd *NodeWebRemoteClient) Restart() error

                  func (*NodeWebRemoteClient) Start

                  func (nd *NodeWebRemoteClient) Start() error

                  func (*NodeWebRemoteClient) StatusEndpoint

                  func (nd *NodeWebRemoteClient) StatusEndpoint() string

                  func (*NodeWebRemoteClient) TLS

                  func (nd *NodeWebRemoteClient) TLS() *tls.Config

                  func (*NodeWebRemoteClient) Terminate

                  func (nd *NodeWebRemoteClient) Terminate() error

                  type OpOption

                  type OpOption func(*op)

                  func WithAgentEndpoints

                  func WithAgentEndpoints(eps []string) OpOption

                    WithAgentEndpoins specifies etcd-agent endpoints. Only applicable for 'etcd-play web' command when deployed with remote machines.

                    func WithLimitInterval

                    func WithLimitInterval(d time.Duration) OpOption

                      WithLimitInterval puts limit interval between terminate and immediate restart, restart and immediate terminate.

                      func WithLiveLog

                      func WithLiveLog() OpOption

                        WithLiveLog feeds etcd logs real-time. Only applicable for 'etcd-play web' command in localhost.

                        type ServerStatus

                        type ServerStatus struct {
                        	Name     string
                        	ID       string
                        	Endpoint string
                        
                        	State string
                        	Hash  int
                        
                        	DbSize    uint64
                        	DbSizeTxt string
                        }

                          ServerStatus encapsulates various statistics about an EtcdServer.