lib

package
v0.0.0-...-146c1f4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2018 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package lib is a generated protocol buffer package.

It is generated from these files:

test.proto

It has these top-level messages:

Test

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentWorkload

func CurrentWorkload() int

CurrentWorkload returns the current workload of the machine

func GetExternalIP

func GetExternalIP() string

GetExternalIP returns external ip

func GetPort

func GetPort() int

GetPort returns the usable port in localhost

func GetPrivilege

func GetPrivilege(workload int) int

GetPrivilege returns the privilege of API according to workload

func HTTPGet

func HTTPGet(url string, config *RequestConfig) ([]byte, error)

HTTPGet returns http response body in []byte, timeout in second

func HTTPGetFile

func HTTPGetFile(url string, config *RequestConfig) (outFName, contentType string, contentLength int64, err error)

HTTPGetFile store body in single file, return file and file's content type

func HTTPPost

func HTTPPost(url string, config *RequestConfig) ([]byte, error)

HTTPPost do http post

func MustGetTlsConfiguration

func MustGetTlsConfiguration(privateKeyFile, certificateFile, caFile string) *tls.Config

func MustLoadCertificates

func MustLoadCertificates(privateKeyFile, certificateFile, caFile string) (tls.Certificate, *x509.CertPool)

func NewHTTPReqeust

func NewHTTPReqeust(method, url string, queries, headers map[string]string, body []byte) (*http.Request, error)

NewHTTPReqeust makes a http request

func RandomString

func RandomString(n int) string

RandomString returns the random string with length of n

func Sizeof

func Sizeof(objs ...interface{}) (sz uint64)

Sizeof returns the estimated memory usage of object(s) not just the size of the type. On 64bit Sizeof("test") == 12 (8 = sizeof(StringHeader) + 4 bytes).

Types

type BoltStorage

type BoltStorage struct {
	// contains filtered or unexported fields
}

func OpenBoltStorage

func OpenBoltStorage(path string, bucket []byte) (*BoltStorage, error)

func (*BoltStorage) Close

func (s *BoltStorage) Close() error

func (*BoltStorage) Delete

func (s *BoltStorage) Delete(bucket []byte, k []byte) error

func (*BoltStorage) ForEach

func (s *BoltStorage) ForEach(bucket []byte, fn func(k, v []byte) error) error

func (*BoltStorage) Get

func (s *BoltStorage) Get(bucket []byte, k []byte) (b []byte, err error)

func (*BoltStorage) Set

func (s *BoltStorage) Set(bucket []byte, k []byte, v []byte) error

func (*BoltStorage) WALName

func (s *BoltStorage) WALName() string

type LimitRate

type LimitRate struct {
	// contains filtered or unexported fields
}

LimitRate 有缺陷,见下面 TODO注释.

func (*LimitRate) GetRate

func (l *LimitRate) GetRate() int

GetRate 获取Rate

func (*LimitRate) Limit

func (l *LimitRate) Limit() bool

Limit waits until the rate is under limit

func (*LimitRate) SetRate

func (l *LimitRate) SetRate(r int)

SetRate 设置Rate

type ProtectVar

type ProtectVar []byte

func (ProtectVar) Free

func (p ProtectVar) Free() error

func (ProtectVar) Pointer

func (p ProtectVar) Pointer() unsafe.Pointer

func (ProtectVar) ReadWrite

func (p ProtectVar) ReadWrite() error

func (ProtectVar) Readonly

func (p ProtectVar) Readonly() error

type RateLimiter

type RateLimiter struct {
	// contains filtered or unexported fields
}

func NewRateLimiter

func NewRateLimiter(limit uint64) *RateLimiter

func (*RateLimiter) Limit

func (r *RateLimiter) Limit() bool

type RequestConfig

type RequestConfig struct {
	Params  map[string]string
	Headers map[string]string
	Timeout uint16
	Body    []byte
	Client  *http.Client
}

func NewReqeustConfig

func NewReqeustConfig(params, headers map[string]string, timeout uint16, body []byte, client *http.Client) *RequestConfig

type SpinLock

type SpinLock struct {
	// contains filtered or unexported fields
}

SpinLock implements a simple atomic spin lock, the zero value for a SpinLock is an unlocked spinlock.

func (*SpinLock) Lock

func (sl *SpinLock) Lock()

Lock locks sl. If the lock is already in use, the caller blocks until Unlock is called

func (*SpinLock) String

func (sl *SpinLock) String() string

func (*SpinLock) TryLock

func (sl *SpinLock) TryLock() bool

TryLock will try to lock sl and return whether it succeed or not without blocking.

func (*SpinLock) Unlock

func (sl *SpinLock) Unlock()

Unlock unlocks sl, unlike [Mutex.Unlock](http://golang.org/pkg/sync/#Mutex.Unlock), there's no harm calling it on an unlocked SpinLock

type Test

type Test struct {
	Label string  `protobuf:"bytes,1,opt,name=label" json:"label,omitempty"`
	Type  int32   `protobuf:"varint,2,opt,name=type" json:"type,omitempty"`
	Reps  []int64 `protobuf:"varint,3,rep,packed,name=reps" json:"reps,omitempty"`
}

func (*Test) Descriptor

func (*Test) Descriptor() ([]byte, []int)

func (*Test) ProtoMessage

func (*Test) ProtoMessage()

func (*Test) Reset

func (m *Test) Reset()

func (*Test) String

func (m *Test) String() string

Jump to

Keyboard shortcuts

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