Documentation ¶
Overview ¶
Package utils contains helper functions and structs used by dragonboat's examples.
Index ¶
- func AssertTrue(b bool)
- func AssertTruef(b bool, format string, a ...interface{})
- func Ceil(size uint32, align uint32) uint32
- func Check(err error)
- func EqualUint32(a, b []uint32) bool
- func Floor(size uint32, align uint32) uint32
- func HumanReadableThroughput(t float64) string
- func Max(a, b int) int
- func Max64(a, b int64) int64
- func Min(a, b int) int
- func MustMarshal(msg proto.Message) []byte
- func MustUnMarshal(data []byte, msg proto.Message)
- func NewMemory(size int) *memory
- func ParseReplicationString(replication string) (int, int, error)
- func SetRandStringBytes(data []byte)
- func SizeOfBlocks(blocks []*pb.Block) uint32
- func SizeVarint(x uint64) (n int)
- func SplitAndTrim(s string, sep string) []string
- type CRC
- type HistogramStatus
- type LockedSource
- type RandomTicker
- type Result
- type SafeMutex
- type Stopper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertTrue ¶
func AssertTrue(b bool)
AssertTrue asserts that b is true. Otherwise, it would log fatal.
func AssertTruef ¶
func EqualUint32 ¶
func HumanReadableThroughput ¶
func MustMarshal ¶
func MustUnMarshal ¶
func SetRandStringBytes ¶
func SetRandStringBytes(data []byte)
func SizeOfBlocks ¶
func SizeVarint ¶
func SplitAndTrim ¶
Types ¶
type HistogramStatus ¶
type HistogramStatus struct {
// contains filtered or unexported fields
}
func NewLantencyStatus ¶
func NewLantencyStatus(start int64, end int64) *HistogramStatus
func (*HistogramStatus) Histgram ¶
func (ls *HistogramStatus) Histgram(percentiles []float64, w io.Writer) []int64
func (*HistogramStatus) Record ¶
func (ls *HistogramStatus) Record(n int64) error
type LockedSource ¶
type LockedSource struct {
// contains filtered or unexported fields
}
thread-safe rand
func (*LockedSource) Int63 ¶
func (r *LockedSource) Int63() int64
func (*LockedSource) Seed ¶
func (r *LockedSource) Seed(seed int64)
type RandomTicker ¶
RandomTicker is similar to time.Ticker but ticks at random intervals between the min and max duration values (stored internally as int64 nanosecond counts).
func NewRandomTicker ¶
func NewRandomTicker(min, max time.Duration) *RandomTicker
NewRandomTicker returns a pointer to an initialized instance of the RandomTicker. Min and max are durations of the shortest and longest allowed ticks. Ticker will run in a goroutine until explicitly stopped.
func (*RandomTicker) Stop ¶
func (rt *RandomTicker) Stop()
Stop terminates the ticker goroutine and closes the C channel.
type SafeMutex ¶
type SafeMutex struct {
// contains filtered or unexported fields
}
SafeMutex can be used in place of sync.RWMutex. It allows code to assert whether the mutex is locked.
func (*SafeMutex) AlreadyLocked ¶
AlreadyLocked returns true if safe mutex is already being held.
func (*SafeMutex) AssertLock ¶
func (s *SafeMutex) AssertLock()
AssertLock asserts whether the lock is being held.
func (*SafeMutex) AssertRLock ¶
func (s *SafeMutex) AssertRLock()
AssertRLock asserts whether the reader lock is being held.
type Stopper ¶
type Stopper struct {
// contains filtered or unexported fields
}
Stopper is a manager struct for managing worker goroutines.
func (*Stopper) Close ¶
func (s *Stopper) Close()
Close closes the internal shouldStopc chan struct{} to signal all worker goroutines that they should stop.
func (*Stopper) RunWorker ¶
func (s *Stopper) RunWorker(f func())
RunWorker creates a new goroutine and invoke the f func in that new worker goroutine.
func (*Stopper) ShouldStop ¶
func (s *Stopper) ShouldStop() chan struct{}
ShouldStop returns a chan struct{} used for indicating whether the Stop() function has been called on Stopper.