util

package
v0.0.0-...-4ac4421 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2018 License: MIT Imports: 11 Imported by: 7

Documentation

Index

Constants

View Source
const (
	REG_WORKER_OK     = 0
	REG_WORKER_FAILED = -1

	HEARTBEAT_INTERVAL = 3
)
View Source
const (
	DATE_TIME_FMT = "2006-01-02 15:04:05"

	DATE_FMT = "2006-01-02"

	TIME_FMT = "15:04:05"

	DATE_TIME_FMT_CN = "2006年01月02日 15时04分05秒"

	DATE_FMT_CN = "2006年01月02日"

	TIME_FMT_CN = "15时04分05秒"
)

FMT_TYPE_NOMAL

View Source
const SecondInNano = 1000 * 1000 * 1000

Variables

This section is empty.

Functions

func Elapse

func Elapse(f func()) int64

Timing the cost of function call, unix nano was returned

func ElapseString

func ElapseString(f func()) string

Timing the cost of function call, unix nano was returned

func GetCurrentTimeFormat

func GetCurrentTimeFormat(format string) string

format

func GetLocalIP

func GetLocalIP() string

func GetMonthDays

func GetMonthDays(year, month int) int

GetMonthDays return days of the month/year

func GetTimeFormat

func GetTimeFormat(second int64, format string) string

func GetTimestamp

func GetTimestamp() int64

return 1441006057 in sec

func GetTimestampInMicro

func GetTimestampInMicro() int64

微秒

func GetTimestampInMicroString

func GetTimestampInMicroString() string

微秒

func GetTimestampInMilli

func GetTimestampInMilli() int64

return 1441007112776 in millisecond

func GetTimestampInMilliString

func GetTimestampInMilliString() string

return 1441007112776 in millisecond

func GetTimestampString

func GetTimestampString() string

return 1441006057 in sec

func HealthcheckHandler

func HealthcheckHandler(w http.ResponseWriter, r *http.Request)

HealthcheckHandler for healthcheck

func HeartbeatForRegistry

func HeartbeatForRegistry(lbHost, svrHost, hcURL string, uriPath []string) error

HeartbeatForRegistry HeartbeatForRegistry

func IsLeapYear

func IsLeapYear(year int) bool

IsLeapYear check whether a year is leay

func NewMultipleHostsReverseProxy

func NewMultipleHostsReverseProxy(targets []*url.URL, transport *http.Transport) *httputil.ReverseProxy

NewMultipleHostsReverseProxy creates reverse proxy instance, the parameter `transport` can be nil, which is used to replace the default one

func SetStructField

func SetStructField(obj interface{}, name string, value interface{}) error

func WriteHTTPResponseAsJson

func WriteHTTPResponseAsJson(w http.ResponseWriter, data interface{}) error

WriteHTTPResponseAsJson write json-data to client

Types

type CommonResp

type CommonResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type LBPolicyEnum

type LBPolicyEnum int
const (
	LB_RANDOM LBPolicyEnum
	LB_ROUNDROBIN
	LB_FASTRESP
)

type LogLevelEnum

type LogLevelEnum int
const (
	LOG_DEBUG LogLevelEnum
	LOG_INFO
	LOG_WARN
	LOG_ERROR
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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