Documentation ¶
Index ¶
- Constants
- func CleanupCallers(cleanAfter time.Duration)
- func DirExists(path string) bool
- func EnsureDir(dirName string, mode int) (bool, error)
- func FileExists(path string) bool
- func HTTPCheck(ctx context.Context, serviceName, URL string, parameters map[string]string, ...) (bool, error)
- func NewCallerLimiter(identifier string, eventsRate rate.Limit, tokenBurst int) *rate.Limiter
- func NewLogger(level, encoding string, outputPaths []string) (*zap.Logger, error)
- func PathExists(path string) bool
- func PkgName() string
- func RedisCheck(serviceName string, addr string, password string, db int) (bool, error)
- type Check
- type Clock
- type ConsulConfig
- type ConsulKv
- func (c *ConsulKv) Delete(ctx context.Context, key string, parameters map[string]string) (string, error)
- func (c *ConsulKv) Read(ctx context.Context, key string, parameters map[string]string) (string, error)
- func (c *ConsulKv) Update(ctx context.Context, key string, value string, parameters map[string]string) (string, error)
- type ConsulStatus
- type Correlation
- type HTTPClient
- type Health
- func (h *Health) AddCheck(ID string, callable func() (bool, error))
- func (h *Health) ChecksReport() (string, error)
- func (h *Health) ChecksStatus() string
- func (h *Health) Down() *Health
- func (h *Health) IsDown() bool
- func (h *Health) IsUnknown() bool
- func (h *Health) IsUp() bool
- func (h *Health) RunChecks()
- func (h *Health) Unknown() *Health
- func (h *Health) Up() *Health
- type Latency
- type Message
- type Metric
- type Point
- type ProcessLimiter
- type Redis
- func (r *Redis) Connect() (bool, error)
- func (r *Redis) Del(key string) (int64, error)
- func (r *Redis) Exists(key string) (bool, error)
- func (r *Redis) Get(key string) (string, error)
- func (r *Redis) HDel(key, field string) (int64, error)
- func (r *Redis) HExists(key, field string) (bool, error)
- func (r *Redis) HGet(key, field string) (string, error)
- func (r *Redis) HLen(key string) (int64, error)
- func (r *Redis) HScan(key string, cursor uint64, match string, count int64) *redis.ScanCmd
- func (r *Redis) HSet(key, field, value string) (bool, error)
- func (r *Redis) HTruncate(key string) (int64, error)
- func (r *Redis) Ping() (bool, error)
- func (r *Redis) Publish(channel string, message string) (bool, error)
- func (r *Redis) Set(key, value string, expiration time.Duration) (bool, error)
- func (r *Redis) Subscribe(channel string, callback func(message Message) error) error
- type SystemStats
- type Task
- type TimeSeries
- type WorkersPool
Constants ¶
const ( // ServiceUp const ServiceUp = "UP" // ServiceDown const ServiceDown = "DOWN" // ServiceUnknown const ServiceUnknown = "UNKNOWN" )
Variables ¶
This section is empty.
Functions ¶
func CleanupCallers ¶
CleanupCallers cleans old clients
func FileExists ¶ added in v1.4.0
FileExists reports whether the named file exists
func HTTPCheck ¶
func HTTPCheck(ctx context.Context, serviceName, URL string, parameters map[string]string, headers map[string]string) (bool, error)
HTTPCheck do HTTP health check
func NewCallerLimiter ¶
NewCallerLimiter create a new rate limiter with an identifier
func PathExists ¶ added in v1.4.0
PathExists reports whether the path exists
Types ¶
type Check ¶
type Check struct { ID string `json:"id"` Status string `json:"status"` Error string `json:"error"` Result bool `json:"result"` // contains filtered or unexported fields }
Check struct
type ConsulKv ¶
type ConsulKv struct {
Config ConsulConfig
}
ConsulKv struct
func (*ConsulKv) Delete ¶
func (c *ConsulKv) Delete(ctx context.Context, key string, parameters map[string]string) (string, error)
Delete deletes a kv
type ConsulStatus ¶
type ConsulStatus struct {
Config ConsulConfig
}
ConsulStatus struct
func (*ConsulStatus) GetRaftLeader ¶
func (c *ConsulStatus) GetRaftLeader(ctx context.Context, parameters map[string]string) (string, error)
GetRaftLeader returns the Raft leader for the datacenter in which the agent is running
func (*ConsulStatus) ListRaftPeers ¶
func (c *ConsulStatus) ListRaftPeers(ctx context.Context, parameters map[string]string) (string, error)
ListRaftPeers retrieves the Raft peers for the datacenter in which the the agent is running
type Correlation ¶
type Correlation interface {
UUIDv4() string
}
Correlation interface
func NewCorrelation ¶
func NewCorrelation() Correlation
NewCorrelation creates an instance of correlation struct
type HTTPClient ¶
type HTTPClient interface { Get(ctx context.Context, endpoint string, parameters map[string]string, headers map[string]string) (*http.Response, error) Post(ctx context.Context, endpoint string, data string, parameters map[string]string, headers map[string]string) (*http.Response, error) Put(ctx context.Context, endpoint string, data string, parameters map[string]string, headers map[string]string) (*http.Response, error) Delete(ctx context.Context, endpoint string, parameters map[string]string, headers map[string]string) (*http.Response, error) BuildParameters(endpoint string, parameters map[string]string) (string, error) ToString(response *http.Response) (string, error) BuildData(parameters map[string]string) string GetStatusCode(response *http.Response) int }
HTTPClient interface
func NewHTTPClient ¶
func NewHTTPClient() HTTPClient
NewHTTPClient creates an instance of http client
type Health ¶
Health struct
func NewHealthChecker ¶
func NewHealthChecker() *Health
NewHealthChecker initializes a new health checker
func (*Health) ChecksReport ¶
ChecksReport get checks Status
type Latency ¶ added in v1.5.0
Latency struct
func NewLatencyTracker ¶ added in v1.5.0
func NewLatencyTracker() *Latency
NewLatencyTracker creates a new latency instance
func (*Latency) GetLatency ¶ added in v1.5.0
GetLatency returns average latency in nanoseconds for specific action
type Metric ¶
Metric struct
func NewMetrics ¶
NewMetrics creates a new metrics array
type Point ¶ added in v1.5.0
Point struct
func (*Point) GetLatency ¶ added in v1.5.0
GetLatency returns latency in nanoseconds
type ProcessLimiter ¶
type ProcessLimiter interface { // Take should block to make sure that the RPS is met. Take() time.Time }
ProcessLimiter interface
func NewProcessLimiter ¶
func NewProcessLimiter(rate int) ProcessLimiter
NewProcessLimiter create a new process rate limiter
type Redis ¶
Redis driver
func NewRedisDriver ¶
NewRedisDriver create a new instance
type SystemStats ¶
type SystemStats struct { EnableCPU bool EnableMem bool EnableGC bool StartTime time.Time Stats map[string]uint64 }
SystemStats stuct
func NewSystemStats ¶
func NewSystemStats(enableCPU, enableMem, enableGC bool) *SystemStats
NewSystemStats creates a new SystemStats
func (*SystemStats) GetStats ¶
func (s *SystemStats) GetStats() map[string]uint64
GetStats get stats list
type TimeSeries ¶
type TimeSeries interface { Connect() error Disconnect() error SendMetrics(metrics []Metric) error SendMetric(metric Metric) error IsNop() bool }
TimeSeries interface
func NewGraphite ¶
func NewGraphite(protocol string, host string, port int, prefix string) TimeSeries
NewGraphite create instance of graphite
type WorkersPool ¶
type WorkersPool struct { Tasks []*Task // contains filtered or unexported fields }
WorkersPool struct
func NewWorkersPool ¶
func NewWorkersPool(tasks []*Task, concurrency int) *WorkersPool
NewWorkersPool initializes a new pool with the given tasks
func (*WorkersPool) Run ¶
func (w *WorkersPool) Run()
Run runs all work within the pool and blocks until it's finished.