oktools

package
v0.0.0-...-164ee4d Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SeparatorByte is a byte that cannot occur in valid UTF-8 sequences and is
	// used to separate label names, label values, and other strings from each other
	// when calculating their combined hash value (aka signature aka fingerprint).
	SeparatorByte byte = 255
)

Variables

This section is empty.

Functions

func AddNotSuccessRetryCondition

func AddNotSuccessRetryCondition(r *resty.Client) *resty.Client

func GenerateHashForMapValues

func GenerateHashForMapValues(labels map[string]string) uint64

func GetAuthRequest

func GetAuthRequest(authorization string) *resty.Request

func GetCusAuthRequest

func GetCusAuthRequest(retryCount int, retryWaitMills int, totalTimeoutSeconds int, authorization string) *resty.Request

retryCount: 重试次数; retryWaitMills: 每次请求之间等待的毫秒数; totalTimeoutSeconds 包括重试,总超时时间; authorization: header Authorization

func GetExternalIP

func GetExternalIP() (net.IP, error)

func GetHostFromUrl

func GetHostFromUrl(urlStr string) (string, string)

return host, path

func GetHttpClient

func GetHttpClient(timeout time.Duration) *http.Client

func GetLocalHostIP

func GetLocalHostIP() (net.IP, error)

GetLocalHostIP :

func GetLocalIpStr

func GetLocalIpStr() (string, error)

func GetMapByArray

func GetMapByArray(pool map[string]string, roles []string) (map[string]string, error)

func GetMonitorRestyClient

func GetMonitorRestyClient(retryCount int, retryWaitMills int, totalTimeoutSeconds int) *resty.Client

retryCount: 重试次数; retryWaitMills: 每次请求之间等待的毫秒数; totalTimeoutSeconds 包括重试,总超时时间; 每个请求超时时间 ~= totalTimeoutSeconds / retryCount

func GetNewRestyClient

func GetNewRestyClient(retryCount int, retryWaitMills int, totalTimeoutSeconds int) *resty.Client

retryCount: 重试次数; retryWaitMills: 每次请求之间等待的毫秒数; totalTimeoutSeconds 包括重试,总超时时间; 每个请求超时时间 ~= totalTimeoutSeconds / retryCount

func GetRestyClient

func GetRestyClient(retryCount int, retryWaitMills int, totalTimeoutSeconds int) *resty.Client

先从缓存查,查不到创建新的 retryCount: 重试次数; retryWaitMills: 每次请求之间等待的毫秒数; totalTimeoutSeconds 包括重试,总超时时间; 每个请求超时时间 ~= totalTimeoutSeconds / retryCount

func GetRestyRetryClient

func GetRestyRetryClient(timeout time.Duration) *resty.Client

func GetShortAuthRequest

func GetShortAuthRequest(authorization string) *resty.Request

func HasKeysInLabels

func HasKeysInLabels(labels map[string]string, keys []string) bool

Types

type Aa

type Aa struct {
}

type SortedTimeStringMapList

type SortedTimeStringMapList []map[string]string

func (SortedTimeStringMapList) Get

func (s SortedTimeStringMapList) Get() []map[string]string

func (SortedTimeStringMapList) Len

func (s SortedTimeStringMapList) Len() int

func (SortedTimeStringMapList) Less

func (s SortedTimeStringMapList) Less(i, j int) bool

func (SortedTimeStringMapList) Swap

func (s SortedTimeStringMapList) Swap(i, j int)

type SyncMap

type SyncMap struct {
	Mutex sync.Mutex
	Cache map[string]interface{}
}

func (*SyncMap) Get

func (s *SyncMap) Get(key string) (interface{}, bool)

func (*SyncMap) GetBool

func (s *SyncMap) GetBool(key string) (bool, bool)

func (*SyncMap) GetString

func (s *SyncMap) GetString(key string) (string, bool)

func (*SyncMap) Put

func (s *SyncMap) Put(key string, value interface{})

func (*SyncMap) Size

func (s *SyncMap) Size() int

Jump to

Keyboard shortcuts

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