util

package
v0.0.0-...-24d954f Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HappoAgentLogLevelDebug shows LogLevel debug
	HappoAgentLogLevelDebug = "debug"
	// HappoAgentLogLevelInfo shows LogLevel info
	HappoAgentLogLevelInfo = "info"
	// HappoAgentLogLevelWarn shows LogLevel warn
	HappoAgentLogLevelWarn = "warn"
	// HappoAgentLogLevelDefault shows default LogLevel
	HappoAgentLogLevelDefault = HappoAgentLogLevelWarn
)

Variables

View Source
var CommandTimeout time.Duration = -1

CommandTimeout is command execution timeout sec

View Source
var Production bool

Production is flag. when production use, set true

Functions

func ACL

func ACL(allowIPs []string) martini.Handler

ACL implements AccessControlList ability

func BindManageParameter

func BindManageParameter(c *cli.Context) (halib.ManageRequest, error)

BindManageParameter build and return ManageRequest

func ExecCommand

func ExecCommand(command string, option string) (int, string, string, error)

ExecCommand execute command with specified timeout behavior

func ExecCommandCombinedOutput

func ExecCommandCombinedOutput(command string, option string) (int, string, error)

ExecCommandCombinedOutput execute command with specified timeout behavior

func GetMartiniRequestStatus

func GetMartiniRequestStatus(fromWhen time.Time) halib.RequestStatusResponse

GetMartiniRequestStatus implements recent request status

func HappoAgentLogger

func HappoAgentLogger() *logrus.Logger

HappoAgentLogger returns custom logger

func HappoAgentLoggerEnableInfo

func HappoAgentLoggerEnableInfo() bool

HappoAgentLoggerEnableInfo returns enable info

func MartiniCustomLogger

func MartiniCustomLogger() martini.Handler

MartiniCustomLogger implements custom logger

func MartiniRequestStatus

func MartiniRequestStatus() martini.Handler

MartiniRequestStatus implements recent request status

func RequestToAutoScalingAPI

func RequestToAutoScalingAPI(endpoint string) (*http.Response, error)

RequestToAutoScalingAPI send request to AutoScalingAPI

func RequestToAutoScalingInstanceAPI

func RequestToAutoScalingInstanceAPI(endpoint, requestType string, postdata []byte) (*http.Response, error)

RequestToAutoScalingInstanceAPI send request to AutoScalingInstanceAPI

func RequestToAutoScalingLeaveAPI

func RequestToAutoScalingLeaveAPI(endpoint string, postdata []byte) (*http.Response, error)

RequestToAutoScalingLeaveAPI send request to AutoScalingInstanceAPI

func RequestToAutoScalingResolveAPI

func RequestToAutoScalingResolveAPI(endpoint string, alias string) (*http.Response, error)

RequestToAutoScalingResolveAPI send request to AutoScalingResolveAPI

func RequestToCheckAvailableAPI

func RequestToCheckAvailableAPI(endpoint string) (*http.Response, error)

RequestToCheckAvailableAPI send request to AutoScalingHealthAPI

func RequestToManageAPI

func RequestToManageAPI(endpoint string, path string, postdata []byte) (*http.Response, error)

RequestToManageAPI send request to ManageAPI

func RequestToMetricAppendAPI

func RequestToMetricAppendAPI(endpoint string, postdata []byte) (*http.Response, error)

RequestToMetricAppendAPI send request to MetricAppendPI

func SetLogLevel

func SetLogLevel(logLevel string)

SetLogLevel parse string and set log level

Types

type HappoAgentFormatter

type HappoAgentFormatter struct {
}

HappoAgentFormatter log formatter for happo-agent

func (*HappoAgentFormatter) Format

func (f *HappoAgentFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format implements HappoAgentFormatter 2006-01-02 15:04:05 [LogLevel] message key=value,key=value...

type LogWriter

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

LogWriter is custom log writer

func NewLogWriter

func NewLogWriter(filename string) *LogWriter

NewLogWriter returns new LogWriter pointer

func (*LogWriter) Close

func (w *LogWriter) Close() error

Close close LogWriter

func (*LogWriter) File

func (w *LogWriter) File() *os.File

File returns fp

func (*LogWriter) ReOpen

func (w *LogWriter) ReOpen() error

ReOpen do reopen logs for rotation

func (*LogWriter) Write

func (w *LogWriter) Write(output []byte) (int, error)

type RequestStatusLog

type RequestStatusLog struct {
	When   time.Time
	URI    string
	Status int
}

RequestStatusLog is data for chan

type RequestStatusManager

type RequestStatusManager struct {
	RequestStatus []struct {
		When   int64
		URI    string
		Counts map[int]uint64
	}
	sync.Mutex
}

RequestStatusManager manages RequestStatus

func (*RequestStatusManager) Append

func (m *RequestStatusManager) Append(when time.Time, uri string, status int)

Append append log to manager

func (*RequestStatusManager) GarbageCollect

func (m *RequestStatusManager) GarbageCollect(when time.Time, lifetimeMinutes int64)

GarbageCollect runs gabage collection

func (*RequestStatusManager) GetStatus

func (m *RequestStatusManager) GetStatus(fromWhen time.Time) halib.RequestStatusResponse

GetStatus returns halib.RequestStatusResponse

type TimeoutError

type TimeoutError struct {
	Message string
}

TimeoutError is error struct show error is timeout

func (*TimeoutError) Error

func (err *TimeoutError) Error() string

Jump to

Keyboard shortcuts

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