utils

package
v0.0.0-...-f468990 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrivateFileMode grants owner to read/write a file.
	PrivateFileMode = 0600
	// PrivateDirMode grants owner to make/remove files inside the directory.
	PrivateDirMode = 0700
)
View Source
const (
	//MySQLBinlogEventType is mysql binlog event flag
	MySQLBinlogEventType byte = iota + 1
	//NodeAttributesType for update the node admin url
	NodeAttributesType
	//SyncerArgsType is syncer start args flag
	SyncerArgsType
	//MasterInfoType is master info flag
	MasterInfoType
	//MasterGtidPurgedType is master gtid_purged flag
	MasterGtidPurgedType
)

Variables

View Source
var (
	//LogSuffix is the log file name suffix
	LogSuffix = ".log"
	//IndexSuffix is the index file name suffix
	IndexSuffix = ".index"
)

Functions

func BytesToString

func BytesToString(b []byte) string

BytesToString implements bytes to string

func DecodeBinlogEvent

func DecodeBinlogEvent(e *raftpb.Entry) *storagepb.BinlogEvent

DecodeBinlogEvent decode raft entry to binlog event

func DirExist

func DirExist(dir string) bool

DirExist check the dir if exist

func EncodeBinlogEvent

func EncodeBinlogEvent(e *storagepb.BinlogEvent) ([]byte, error)

EncodeBinlogEvent encode binlog event to data

func ExistLog

func ExistLog(dirpath string) bool

ExistLog check log file if exist

func GetIndexName

func GetIndexName(segmentName string) string

GetIndexName get the index file name by segment name

func GetIndexPath

func GetIndexPath(logPath string) string

GetIndexPath get index path by log path

func IsBinlogEvent

func IsBinlogEvent(e *raftpb.Entry) bool

IsBinlogEvent check the raft entry is binlog event

func IsDirWriteable

func IsDirWriteable(dir string) error

IsDirWriteable check dir if writeable

func MustMarshal

func MustMarshal(m Marshaler) []byte

MustMarshal execute occur error will panic

func MustUnmarshal

func MustUnmarshal(um Unmarshaler, data []byte)

MustUnmarshal execute occur error will panic

func NewUniformSample

func NewUniformSample(reservoirSize int) metrics.Sample

NewUniformSample constructs a new uniform sample with the given reservoir size.

func ReadDir

func ReadDir(dirname string) ([]os.FileInfo, error)

ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename.

func StringToBytes

func StringToBytes(s string) []byte

StringToBytes implements string to bytes

Types

type Broadcast

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

Broadcast allows to send a signal to all listeners

func NewBroadcast

func NewBroadcast() *Broadcast

NewBroadcast creates a new broadcast

func (*Broadcast) Receive

func (b *Broadcast) Receive() <-chan struct{}

Receive a channel on which the next (close) signal will be sent

func (*Broadcast) Send

func (b *Broadcast) Send()

Send a signal to all listeners

type Marshaler

type Marshaler interface {
	Marshal() (data []byte, err error)
}

Marshaler implements stuct to byte

type Resp

type Resp struct {
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

Resp is the response return to client

func NewResp

func NewResp() *Resp

NewResp create a Resp

func SendRequest

func SendRequest(method string, leaderURL string, data []byte) (*Resp, error)

SendRequest send PUT request to leader

func (*Resp) SetData

func (r *Resp) SetData(data interface{}) *Resp

SetData set data into Resp

func (*Resp) SetError

func (r *Resp) SetError(msg string) *Resp

SetError set error into Resp

type UniformSample

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

UniformSample is a metric sample

func (*UniformSample) Clear

func (s *UniformSample) Clear()

Clear clears all samples.

func (*UniformSample) Count

func (s *UniformSample) Count() int64

Count returns the number of samples recorded, which may exceed the reservoir size.

func (*UniformSample) Max

func (s *UniformSample) Max() int64

Max returns the maximum value in the sample, which may not be the maximum value ever to be part of the sample.

func (*UniformSample) Mean

func (s *UniformSample) Mean() float64

Mean returns the mean of the values in the sample.

func (*UniformSample) Min

func (s *UniformSample) Min() int64

Min returns the minimum value in the sample, which may not be the minimum value ever to be part of the sample.

func (*UniformSample) Percentile

func (s *UniformSample) Percentile(p float64) float64

Percentile returns an arbitrary percentile of values in the sample.

func (*UniformSample) Percentiles

func (s *UniformSample) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of values in the sample.

func (*UniformSample) Size

func (s *UniformSample) Size() int

Size returns the size of the sample, which is at most the reservoir size.

func (*UniformSample) Snapshot

func (s *UniformSample) Snapshot() metrics.Sample

Snapshot returns a read-only copy of the sample.

func (*UniformSample) StdDev

func (s *UniformSample) StdDev() float64

StdDev returns the standard deviation of the values in the sample.

func (*UniformSample) Sum

func (s *UniformSample) Sum() int64

Sum returns the sum of the values in the sample.

func (*UniformSample) Update

func (s *UniformSample) Update(v int64)

Update samples a new value.

func (*UniformSample) Values

func (s *UniformSample) Values() []int64

Values returns a copy of the values in the sample.

func (*UniformSample) Variance

func (s *UniformSample) Variance() float64

Variance returns the variance of the values in the sample.

type Unmarshaler

type Unmarshaler interface {
	Unmarshal(data []byte) error
}

Unmarshaler implements byte to struct

Jump to

Keyboard shortcuts

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