nerve

package
v0.0.0-...-ea53830 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: GPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCommand

func ExecCommand(cmd []string, timeoutInMilli int) error

func ExecCommandFull

func ExecCommandFull(cmd []string, env []string, timeoutInMilli int) error

func IpLookup

func IpLookup(host string, preferIPv4 bool) (net.IP, error)

func IpLookupNoError

func IpLookupNoError(host string, preferIPv4 bool) net.IP

func Logger

func Logger() macaron.Handler

func ParseBoolFlag

func ParseBoolFlag(value string) bool

Types

type Check

type Check struct {
	Checker Checker
	Status  error
}

type CheckAmqp

type CheckAmqp struct {
	CheckCommon
	Datasource string `json:"datasource,omitempty"`
	Vhost      string `json:"vhost,omitempty"`
	Queue      string `json:"queue,omitempty"`
	Username   string `json:"username,omitempty"`
	Password   string `json:"password,omitempty"`
	// contains filtered or unexported fields
}

func NewCheckAmqp

func NewCheckAmqp() *CheckAmqp

func (*CheckAmqp) Check

func (x *CheckAmqp) Check() error

func (*CheckAmqp) Init

func (x *CheckAmqp) Init(s *Service) error

func (*CheckAmqp) Run

func (x *CheckAmqp) Run(statusChange chan Check, stop <-chan struct{}, doneWait *sync.WaitGroup)

type CheckCommon

type CheckCommon struct {
	Type                 string `json:"type,omitempty"`
	Host                 string `json:"host,omitempty"`
	Port                 *int   `json:"port,omitempty"`
	TimeoutInMilli       *int   `json:"timeoutInMilli,omitempty"`
	Rise                 *int   `json:"rise,omitempty"`
	Fall                 *int   `json:"fall,omitempty"`
	CheckIntervalInMilli *int   `json:"checkIntervalInMilli,omitempty"`
	// contains filtered or unexported fields
}

func (*CheckCommon) CommonInit

func (c *CheckCommon) CommonInit(s *Service) error

func (*CheckCommon) CommonRun

func (c *CheckCommon) CommonRun(checker Checker, statusChange chan<- Check, stop <-chan struct{}, doneWait *sync.WaitGroup)

func (*CheckCommon) GetFields

func (c *CheckCommon) GetFields() data.Fields

type CheckExec

type CheckExec struct {
	CheckCommon
	Command []string `json:"command,omitempty"`
}

func NewCheckExec

func NewCheckExec() *CheckExec

func (*CheckExec) Check

func (x *CheckExec) Check() error

func (*CheckExec) Init

func (x *CheckExec) Init(s *Service) error

func (*CheckExec) Run

func (x *CheckExec) Run(statusChange chan Check, stop <-chan struct{}, doneWait *sync.WaitGroup)

type CheckHttp

type CheckHttp struct {
	CheckCommon
	Path string `json:"namespace,omitempty"`
	// contains filtered or unexported fields
}

func NewCheckHttp

func NewCheckHttp() *CheckHttp

func (*CheckHttp) Check

func (x *CheckHttp) Check() error

func (*CheckHttp) Init

func (x *CheckHttp) Init(s *Service) error

func (*CheckHttp) Run

func (x *CheckHttp) Run(statusChange chan Check, stop <-chan struct{}, doneWait *sync.WaitGroup)

func (*CheckHttp) String

func (x *CheckHttp) String() string

type CheckHttps

type CheckHttps struct {
	CheckCommon
	Path string `json:"path,omitempty"`
	// contains filtered or unexported fields
}

func NewCheckHttps

func NewCheckHttps() *CheckHttps

func (*CheckHttps) Check

func (x *CheckHttps) Check() error

func (*CheckHttps) Init

func (x *CheckHttps) Init(s *Service) error

func (*CheckHttps) Run

func (x *CheckHttps) Run(statusChange chan Check, stop <-chan struct{}, doneWait *sync.WaitGroup)

func (*CheckHttps) String

func (x *CheckHttps) String() string

type CheckKubernetes

type CheckKubernetes struct {
	CheckCommon
	Namespace string `json:"namespace,omitempty"`
	PodName   string `json:"podName,omitempty"`
	// contains filtered or unexported fields
}

func NewCheckKubernetes

func NewCheckKubernetes() *CheckKubernetes

func (*CheckKubernetes) Check

func (x *CheckKubernetes) Check() error

func (*CheckKubernetes) Init

func (x *CheckKubernetes) Init(s *Service) error

func (*CheckKubernetes) Run

func (x *CheckKubernetes) Run(statusChange chan Check, stop <-chan struct{}, doneWait *sync.WaitGroup)

type CheckProxyHttp

type CheckProxyHttp struct {
	CheckCommon
	ProxyHost            string   `json:"proxyHost,omitempty"`
	ProxyPort            int      `json:"proxyPort,omitempty"`
	ProxyUsername        string   `json:"proxyUsername,omitempty"`
	ProxyPassword        string   `json:"proxyPassword,omitempty"`
	Urls                 []string `json:"urls,omitempty"`
	FailOnAnyUnreachable bool     `json:"failOnAnyUnreachable,omitempty"`
	// contains filtered or unexported fields
}

func NewCheckProxyHttp

func NewCheckProxyHttp() *CheckProxyHttp

func (*CheckProxyHttp) Check

func (x *CheckProxyHttp) Check() error

func (*CheckProxyHttp) Init

func (x *CheckProxyHttp) Init(s *Service) error

func (*CheckProxyHttp) Run

func (x *CheckProxyHttp) Run(statusChange chan Check, stop <-chan struct{}, doneWait *sync.WaitGroup)

type CheckSql

type CheckSql struct {
	CheckCommon
	Username   string `json:"username,omitempty"`
	Password   string `json:"password,omitempty"`
	Request    string `json:"request,omitempty"`
	Datasource string `json:"datasource,omitempty"`
	Driver     string `json:"driver,omitempty"`
	// contains filtered or unexported fields
}

func NewCheckSql

func NewCheckSql() *CheckSql

func (*CheckSql) Check

func (x *CheckSql) Check() error

func (*CheckSql) Init

func (x *CheckSql) Init(s *Service) error

func (*CheckSql) Run

func (x *CheckSql) Run(statusChange chan Check, stop <-chan struct{}, doneWait *sync.WaitGroup)

type CheckTcp

type CheckTcp struct {
	CheckCommon
	// contains filtered or unexported fields
}

func NewCheckTcp

func NewCheckTcp() *CheckTcp

func (*CheckTcp) Check

func (x *CheckTcp) Check() error

func (*CheckTcp) Init

func (x *CheckTcp) Init(s *Service) error

func (*CheckTcp) Run

func (x *CheckTcp) Run(statusChange chan Check, stop <-chan struct{}, doneWait *sync.WaitGroup)

type Checker

type Checker interface {
	Init(service *Service) error
	Check() error
	GetFields() data.Fields
	Run(statusChange chan Check, stop <-chan struct{}, doneWait *sync.WaitGroup)
}

func CheckerFromJson

func CheckerFromJson(data []byte, s *Service) (Checker, error)

type Nerve

type Nerve struct {
	LogLevel            *logs.Level `json:"logLevel,omitempty"`
	ApiHost             string      `json:"apiHost,omitempty"`
	ApiPort             int         `json:"apiPort,omitempty"`
	Services            []*Service  `json:"services,omitempty"`
	TemplatedConfigPath string      `json:"templatedConfigPath,omitempty"`
	// contains filtered or unexported fields
}

func (*Nerve) DisableServices

func (n *Nerve) DisableServices(ctx *macaron.Context)

func (*Nerve) EnableServices

func (n *Nerve) EnableServices(ctx *macaron.Context)

func (*Nerve) Init

func (n *Nerve) Init(version string, buildTime string, logLevelIsSet bool) error

func (*Nerve) ServiceDisable

func (n *Nerve) ServiceDisable(ctx *macaron.Context)

func (*Nerve) ServiceEnable

func (n *Nerve) ServiceEnable(ctx *macaron.Context)

func (*Nerve) ServiceStatus

func (n *Nerve) ServiceStatus(ctx *macaron.Context)

func (*Nerve) ServiceWeight

func (n *Nerve) ServiceWeight(ctx *macaron.Context)

func (*Nerve) ServicesStatus

func (n *Nerve) ServicesStatus(ctx *macaron.Context)

func (*Nerve) ServicesWeight

func (n *Nerve) ServicesWeight(ctx *macaron.Context)

func (*Nerve) Start

func (n *Nerve) Start(startStatus chan error)

func (*Nerve) Stop

func (n *Nerve) Stop()

type Port

type Port int

func (*Port) UnmarshalJSON

func (p *Port) UnmarshalJSON(b []byte) error

type Report

type Report struct {
	Available            *bool             `json:"available"`
	UnavailableReason    string            `json:"unavailable_reason,omitempty"`
	Host                 string            `json:"host,omitempty"`
	Port                 Port              `json:"port,omitempty"`
	Name                 string            `json:"name,omitempty"`
	HaProxyServerOptions string            `json:"haproxy_server_options,omitempty"`
	Weight               *uint8            `json:"weight"`
	Labels               map[string]string `json:"labels,omitempty"`
}

func NewReport

func NewReport(content []byte) (*Report, error)

func (*Report) String

func (r *Report) String() string

func (*Report) UnmarshalJSON

func (r *Report) UnmarshalJSON(b []byte) error

type Reporter

type Reporter interface {
	Report(report Report) error
	Init(s *Service) error
	Destroy()

	GetFields() data.Fields
	// contains filtered or unexported methods
}

func ReporterFromJson

func ReporterFromJson(data []byte, s *Service) (Reporter, error)

type ReporterCommon

type ReporterCommon struct {
	Type string `json:"type,omitempty"`
	// contains filtered or unexported fields
}

func (*ReporterCommon) Destroy

func (r *ReporterCommon) Destroy()

func (*ReporterCommon) GetFields

func (r *ReporterCommon) GetFields() data.Fields

func (*ReporterCommon) Init

func (r *ReporterCommon) Init(s *Service) error

type ReporterConsole

type ReporterConsole struct {
	ReporterCommon
	// contains filtered or unexported fields
}

func NewReporterConsole

func NewReporterConsole() *ReporterConsole

func (*ReporterConsole) Init

func (r *ReporterConsole) Init(s *Service) error

func (*ReporterConsole) Report

func (r *ReporterConsole) Report(report Report) error

type ReporterFile

type ReporterFile struct {
	ReporterCommon
	Path   string `json:"path,omitempty"`
	Append bool   `json:"append,omitempty"`
}

func NewReporterFile

func NewReporterFile() *ReporterFile

func (*ReporterFile) Init

func (r *ReporterFile) Init(s *Service) error

func (*ReporterFile) Report

func (r *ReporterFile) Report(report Report) error

type ReporterZookeeper

type ReporterZookeeper struct {
	ReporterCommon
	Path                     string   `json:"path,omitempty"`
	Hosts                    []string `json:"hosts,omitempty"`
	ConnectionTimeoutInMilli *int     `json:"connectionTimeoutInMilli,omitempty"`
	RefreshIntervalInMilli   *int     `json:"refreshIntervalInMilli,omitempty"`
	ExposeOnUnavailable      bool     `json:"exposeOnUnavailable,omitempty"`
	// contains filtered or unexported fields
}

func NewReporterZookeeper

func NewReporterZookeeper() *ReporterZookeeper

func (*ReporterZookeeper) Destroy

func (r *ReporterZookeeper) Destroy()

func (*ReporterZookeeper) Init

func (r *ReporterZookeeper) Init(s *Service) error

func (*ReporterZookeeper) Report

func (r *ReporterZookeeper) Report(report Report) error

type Service

type Service struct {
	Name                       string            `json:"name,omitempty"`
	Port                       int               `json:"port,omitempty"`
	Host                       string            `json:"host,omitempty"`
	PreferIpv4                 bool              `json:"preferIpv4,omitempty"`
	Weight                     uint8             `json:"weight,omitempty"`
	Checks                     []json.RawMessage `json:"checks,omitempty"`
	Reporters                  []json.RawMessage `json:"reporters,omitempty"`
	ReporterServiceName        string            `json:"reporterServiceName,omitempty"`
	ReportReplayInMilli        *int              `json:"reportReplayInMilli,omitempty"`
	HaproxyServerOptions       string            `json:"haproxyServerOptions,omitempty"`
	SetServiceAsDownOnShutdown *bool             `json:"setServiceAsDownOnShutdown,omitempty"`
	Labels                     map[string]string `json:"labels,omitempty"`
	ExcludeFromGlobalDisable   bool              `json:"excludeFromGlobalDisable,omitempty"`

	PreAvailableCommand            []string `json:"preAvailableCommand,omitempty"`
	PreAvailableMaxDurationInMilli *int     `json:"preAvailableMaxDurationInMilli,omitempty"`

	EnableCheckStableCommand            []string `json:"enableCheckStableCommand,omitempty"`
	EnableCheckStableMaxDurationInMilli *int     `json:"enableCheckStableMaxDurationInMilli,omitempty"`
	EnableCheckStableIntervalInMilli    *int     `json:"enableCheckStableIntervalInMilli,omitempty"`

	EnableWarmupIntervalInMilli    *int `json:"enableWarmupIntervalInMilli,omitempty"`
	EnableWarmupMaxDurationInMilli *int `json:"enableWarmupMaxDurationInMilli,omitempty"`

	DisableShutdownCommand               []string `json:"disableShutdownCommand,omitempty"`
	DisableShutdownMaxDurationInMilli    *int     `json:"disableShutdownMaxDurationInMilli,omitempty"`
	DisableGracefullyDoneCommand         []string `json:"disableGracefullyDoneCommand,omitempty"`
	DisableGracefullyDoneIntervalInMilli *int     `json:"disableGracefullyDoneIntervalInMilli,omitempty"`
	DisableMaxDurationInMilli            *int     `json:"disableMaxDurationInMilli,omitempty"`
	DisableMinDurationInMilli            *int     `json:"disableMinDurationInMilli,omitempty"`
	NoMetrics                            bool     `json:"noMetrics,omitempty"`
	// contains filtered or unexported fields
}

func (*Service) CurrentWeight

func (s *Service) CurrentWeight() uint8

func (*Service) Disable

func (s *Service) Disable(doneWaiter *sync.WaitGroup, shutdown bool)

func (*Service) Enable

func (s *Service) Enable(force bool)

func (*Service) Init

func (s *Service) Init(n *Nerve) error

func (*Service) Start

func (s *Service) Start(stopper <-chan struct{}, stopWait *sync.WaitGroup)

func (*Service) Warmup

func (s *Service) Warmup(giveUp <-chan struct{})

type ServiceStatus

type ServiceStatus struct {
	Name          string
	Host          string
	Port          int
	Status        string
	MaxWeight     int
	CurrentWeight int
	Available     bool
}

type SharedZkConnection

type SharedZkConnection struct {
	Conn *zk.Conn
	// contains filtered or unexported fields
}

func NewSharedZkConnection

func NewSharedZkConnection(hosts []string, timeout time.Duration) (*SharedZkConnection, error)

this reuse zk connection if host list is the same a new dedicated event chan is created for each call zk events are duplicated to all those channels

func (*SharedZkConnection) Close

func (z *SharedZkConnection) Close()

func (*SharedZkConnection) CreateEphemeral

func (z *SharedZkConnection) CreateEphemeral(path string, data []byte, acl []zk.ACL) (string, error)

func (*SharedZkConnection) Subscribe

func (z *SharedZkConnection) Subscribe() <-chan zk.Event

type ZKLogger

type ZKLogger struct {
}

func (ZKLogger) Printf

func (zl ZKLogger) Printf(format string, data ...interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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