Documentation ¶
Index ¶
- Constants
- Variables
- func AnalyzeIPAndPort(address string) (ip string, port int)
- func ArrayCopy(src []interface{}, srcPos int32, target []interface{}, targetPos int32, ...)
- func CheckErr(err error)
- func Checksum(b []byte) uint64
- func Checksum2Long(a, b uint64) uint64
- func DeregisterSubscriber(s Subscriber)
- func Exist(path string) bool
- func FillTargetElement(array []interface{}, e interface{})
- func GetBoolFromEnv(key string) (bool, error)
- func GetBoolFromEnvOptional(key string, defVal bool) bool
- func GetCurrentTimeMs() int64
- func GetCurrentTimeNs() int64
- func GetInt16FromEnv(key string) int16
- func GetInt16FromEnvOptional(key string, defVal int16) int16
- func GetInt32FromEnv(key string) int32
- func GetInt32FromEnvOptional(key string, defVal int32) int32
- func GetInt64FormBytes(memory []byte, index int) int64
- func GetInt64FromEnv(key string) int64
- func GetInt64FromEnvOptional(key string, defVal int64) int64
- func GetInt8FromEnv(key string) int8
- func GetInt8FromEnvOptional(key string, defVal int8) int8
- func GetIntFromEnv(key string) (int, error)
- func GetIntFromEnvOptional(key string, defVal int) int
- func GetStringFromEnv(key string) string
- func Home() (string, error)
- func IF(expression bool, a, b interface{}) interface{}
- func InitEventCenter()
- func IsIOError(err error) bool
- func ParseToInt(val string) int
- func ParseToInt16(val string) int16
- func ParseToInt32(val string) int32
- func ParseToInt64(val string) int64
- func ParseToInt8(val string) int8
- func ParseToUint16(val string) uint16
- func ParseToUint32(val string) uint32
- func ParseToUint64(val string) uint64
- func ParseToUint8(val string) uint8
- func PrintStack() string
- func PublishEvent(event ...Event) error
- func PublishEventNonBlock(event ...Event) (bool, error)
- func PublishEventWithTimeout(timeout time.Duration, events ...Event) (bool, error)
- func RegisterPublisher(ctx context.Context, event Event, ringBufferSize int64) error
- func RegisterPublisherDefault(ctx context.Context, event Event) error
- func RegisterSubscriber(s Subscriber) error
- func RequireFalse(expression bool, format string, args ...interface{})
- func RequireNonNil(e interface{}, msg string) (interface{}, error)
- func RequireTrue(expression bool, format string, args ...interface{}) error
- func Shutdown()
- func TestRegisterOnExpire(f func(event Event))
- type AtomicInt64
- type BinarySearchTree
- func (bTree *BinarySearchTree) Delete(v interface{})
- func (bTree *BinarySearchTree) Find(v interface{}) *node
- func (bTree *BinarySearchTree) FindMax() *node
- func (bTree *BinarySearchTree) FindMin() *node
- func (bTree *BinarySearchTree) FindNearbyLeft(v interface{}) *node
- func (bTree *BinarySearchTree) FindNearbyRight(v string) *node
- func (bTree *BinarySearchTree) Insert(v interface{}, replaceOld bool)
- func (bTree *BinarySearchTree) Range(call func(n *node))
- func (bTree *BinarySearchTree) SeekLevel() [][]*node
- type ConcurrentMap
- func (cm *ConcurrentMap) Clear()
- func (cm *ConcurrentMap) ComputeIfAbsent(key interface{}, function func(key interface{}) interface{}) interface{}
- func (cm *ConcurrentMap) Contains(k interface{}) bool
- func (cm *ConcurrentMap) ForEach(consumer func(k, v interface{}))
- func (cm *ConcurrentMap) Get(k interface{}) interface{}
- func (cm *ConcurrentMap) Keys() []interface{}
- func (cm *ConcurrentMap) Put(k, v interface{})
- func (cm *ConcurrentMap) PutIfAbsent(key, val interface{}) interface{}
- func (cm *ConcurrentMap) Remove(k interface{})
- func (cm *ConcurrentMap) Size() int
- func (cm *ConcurrentMap) Values() []interface{}
- type ConcurrentSlice
- func (cs *ConcurrentSlice) Add(v interface{})
- func (cs *ConcurrentSlice) ForEach(consumer func(index int, v interface{}))
- func (cs *ConcurrentSlice) Get(index int32) (interface{}, error)
- func (cs *ConcurrentSlice) GetFirst() interface{}
- func (cs *ConcurrentSlice) GetLast() interface{}
- func (cs *ConcurrentSlice) Remove(v interface{})
- func (cs *ConcurrentSlice) Size() int32
- type CountDownEvent
- type Event
- type EventCenter
- type LifeCycle
- type Publisher
- type Segment
- func (s *Segment) Add(e interface{})
- func (s *Segment) AddAll(src []interface{}, srcPos, size int32)
- func (s *Segment) Cap() int32
- func (s *Segment) Clear()
- func (s *Segment) Get(index int32) interface{}
- func (s *Segment) IsEmpty() bool
- func (s *Segment) IsReachEnd() bool
- func (s *Segment) PeekFirst() interface{}
- func (s *Segment) PeekLast() interface{}
- func (s *Segment) RemoveFromFirst(toIndex int32) int32
- func (s *Segment) RemoveFromFirstWhen(predicate func(v interface{}) bool) int32
- func (s *Segment) RemoveFromLastWhen(predicate func(v interface{}) bool) int32
- func (s *Segment) Size() int32
- type SegmentList
- func (sl *SegmentList) Add(e interface{})
- func (sl *SegmentList) AddAll(arr []interface{})
- func (sl *SegmentList) Clear()
- func (sl *SegmentList) Get(index int32) interface{}
- func (sl *SegmentList) GetFirst() *Segment
- func (sl *SegmentList) GetLast() *Segment
- func (sl *SegmentList) IsEmpty() bool
- func (sl *SegmentList) PeekFirst() interface{}
- func (sl *SegmentList) PeekLast() interface{}
- func (sl *SegmentList) RemoveFromFirst(toIndex int32)
- func (sl *SegmentList) RemoveFromFirstWhen(predicate func(v interface{}) bool)
- func (sl *SegmentList) RemoveFromLastWhen(predicate func(v interface{}) bool)
- func (sl *SegmentList) SegmentsSize() int32
- func (sl *SegmentList) Size() int32
- type Set
- func (s *Set) Add(value interface{})
- func (s *Set) AddAll(values ...interface{})
- func (s *Set) AddAllWithSet(set *Set)
- func (s *Set) Contain(value interface{}) bool
- func (s *Set) IsEmpty() bool
- func (s *Set) Range(f func(value interface{}))
- func (s *Set) Remove(value interface{})
- func (s *Set) RemoveAll(arr ...interface{})
- func (s *Set) RemoveAllWithSet(set *Set)
- func (s *Set) RetainAll(arr ...interface{})
- func (s *Set) RetainAllWithSet(set *Set)
- func (s *Set) Size() int
- func (s *Set) ToSlice(arr ...interface{})
- type Subscriber
- type SyncSet
- type TreeMap
- func (tMap *TreeMap) Clear()
- func (tMap *TreeMap) ComputeIfAbsent(key interface{}, supplier func() interface{}) interface{}
- func (tMap *TreeMap) Get(key interface{}) interface{}
- func (tMap *TreeMap) IsEmpty() bool
- func (tMap *TreeMap) Put(key, val interface{})
- func (tMap *TreeMap) RangeEntry(consumer func(k, v interface{}))
- func (tMap *TreeMap) RangeLessThan(key interface{}, consumer func(k, v interface{}))
- func (tMap *TreeMap) RemoveKey(key interface{})
- func (tMap *TreeMap) Size() int64
Constants ¶
View Source
const ( SegmentShift = 7 SegmentSize = 2 << (SegmentShift - 1) )
View Source
const (
ErrNonNilMsg = "%s must not nil"
)
View Source
const (
IndexOutOfBoundErrMsg = "index out of bound, index=%d, offset=%d, pos=%s"
)
View Source
const (
Int64MaxValue = int64(math.MaxInt64)
)
Variables ¶
View Source
var ( IPAny = "0.0.0.0" EmptyBytes []byte )
View Source
var ( ErrorEventNotRegister = errors.New("the event was not registered") ErrorEventRegister = errors.New("register event publisher failed") ErrorAddSubscriber = errors.New("add subscriber failed") )
View Source
var (
Crc64Table = crc64.MakeTable(uint64(528))
)
View Source
var (
ErrArrayOutOfBound = errors.New("array out of bound")
)
View Source
var RaftDefaultScheduler = common.NewRoutinePool(256, 128)
View Source
var (
RaftLog = logger.NewTestLogger("LRaft")
)
Functions ¶
func AnalyzeIPAndPort ¶
func Checksum2Long ¶
func DeregisterSubscriber ¶
func DeregisterSubscriber(s Subscriber)
func FillTargetElement ¶
func FillTargetElement(array []interface{}, e interface{})
func GetBoolFromEnv ¶
func GetBoolFromEnvOptional ¶
func GetCurrentTimeMs ¶
func GetCurrentTimeMs() int64
func GetCurrentTimeNs ¶
func GetCurrentTimeNs() int64
func GetInt16FromEnv ¶
func GetInt16FromEnvOptional ¶
func GetInt32FromEnv ¶
func GetInt32FromEnvOptional ¶
func GetInt64FormBytes ¶
func GetInt64FromEnv ¶
func GetInt64FromEnvOptional ¶
func GetInt8FromEnv ¶
func GetInt8FromEnvOptional ¶
func GetIntFromEnv ¶
func GetIntFromEnvOptional ¶
func GetStringFromEnv ¶
func InitEventCenter ¶
func InitEventCenter()
func ParseToInt ¶
func ParseToInt16 ¶
func ParseToInt32 ¶
func ParseToInt64 ¶
func ParseToInt8 ¶
func ParseToUint16 ¶
func ParseToUint32 ¶
func ParseToUint64 ¶
func ParseToUint8 ¶
func PrintStack ¶
func PrintStack() string
func PublishEvent ¶
func PublishEventNonBlock ¶
func PublishEventWithTimeout ¶
func RegisterPublisher ¶
func RegisterSubscriber ¶
func RegisterSubscriber(s Subscriber) error
func RequireFalse ¶
func RequireNonNil ¶
func RequireTrue ¶
func TestRegisterOnExpire ¶
func TestRegisterOnExpire(f func(event Event))
Types ¶
type AtomicInt64 ¶
type AtomicInt64 struct {
// contains filtered or unexported fields
}
func NewAtomicInt64 ¶
func NewAtomicInt64() AtomicInt64
func (AtomicInt64) Decrement ¶
func (a AtomicInt64) Decrement() int64
func (AtomicInt64) Increment ¶
func (a AtomicInt64) Increment() int64
func (AtomicInt64) Value ¶
func (a AtomicInt64) Value() int64
type BinarySearchTree ¶
type BinarySearchTree struct {
// contains filtered or unexported fields
}
func NewBinarySearchTree ¶
func NewBinarySearchTree(compare func(a, b interface{}) int) *BinarySearchTree
func (*BinarySearchTree) Delete ¶
func (bTree *BinarySearchTree) Delete(v interface{})
func (*BinarySearchTree) Find ¶
func (bTree *BinarySearchTree) Find(v interface{}) *node
func (*BinarySearchTree) FindMax ¶
func (bTree *BinarySearchTree) FindMax() *node
func (*BinarySearchTree) FindMin ¶
func (bTree *BinarySearchTree) FindMin() *node
func (*BinarySearchTree) FindNearbyLeft ¶
func (bTree *BinarySearchTree) FindNearbyLeft(v interface{}) *node
5 / \ 3 8 / \ / \ 1 4 7 9
if you find 5, will return 3, if find 1, will return nil
func (*BinarySearchTree) FindNearbyRight ¶
func (bTree *BinarySearchTree) FindNearbyRight(v string) *node
5 / \ 3 8 / \ / \ 1 4 7 9
if you find 5, will return 7, if find 8, will return 9
func (*BinarySearchTree) Insert ¶
func (bTree *BinarySearchTree) Insert(v interface{}, replaceOld bool)
func (*BinarySearchTree) Range ¶
func (bTree *BinarySearchTree) Range(call func(n *node))
func (*BinarySearchTree) SeekLevel ¶
func (bTree *BinarySearchTree) SeekLevel() [][]*node
type ConcurrentMap ¶
type ConcurrentMap struct {
// contains filtered or unexported fields
}
ConcurrentMap 并发map,读读不阻塞
func NewConcurrentMap ¶
func NewConcurrentMap() *ConcurrentMap
NewConcurrentMap 创建一个新的 ConcurrentMap
func (*ConcurrentMap) ComputeIfAbsent ¶
func (cm *ConcurrentMap) ComputeIfAbsent(key interface{}, function func(key interface{}) interface{}) interface{}
ComputeIfAbsent 懒Put操作,通过 key 计算是否存在该 key,如果存在,直接返回,否则执行 function 方法计算对应的 value
func (*ConcurrentMap) Contains ¶
func (cm *ConcurrentMap) Contains(k interface{}) bool
Contains 判断是否包含某个 key
func (*ConcurrentMap) ForEach ¶
func (cm *ConcurrentMap) ForEach(consumer func(k, v interface{}))
ForEach 遍历所有的 key-value
func (*ConcurrentMap) Get ¶
func (cm *ConcurrentMap) Get(k interface{}) interface{}
Get 根据 key 获取一个数据
func (*ConcurrentMap) PutIfAbsent ¶
func (cm *ConcurrentMap) PutIfAbsent(key, val interface{}) interface{}
PutIfAbsent
func (*ConcurrentMap) Remove ¶
func (cm *ConcurrentMap) Remove(k interface{})
Remove 根据 key 删除一个 key-value
func (*ConcurrentMap) Values ¶
func (cm *ConcurrentMap) Values() []interface{}
Values 获取所有的 value 数组
type ConcurrentSlice ¶
type ConcurrentSlice struct {
// contains filtered or unexported fields
}
func (*ConcurrentSlice) Add ¶
func (cs *ConcurrentSlice) Add(v interface{})
func (*ConcurrentSlice) ForEach ¶
func (cs *ConcurrentSlice) ForEach(consumer func(index int, v interface{}))
func (*ConcurrentSlice) Get ¶
func (cs *ConcurrentSlice) Get(index int32) (interface{}, error)
func (*ConcurrentSlice) GetFirst ¶
func (cs *ConcurrentSlice) GetFirst() interface{}
func (*ConcurrentSlice) GetLast ¶
func (cs *ConcurrentSlice) GetLast() interface{}
func (*ConcurrentSlice) Remove ¶
func (cs *ConcurrentSlice) Remove(v interface{})
func (*ConcurrentSlice) Size ¶
func (cs *ConcurrentSlice) Size() int32
type CountDownEvent ¶
type CountDownEvent struct {
// contains filtered or unexported fields
}
func NewCountDownEvent ¶
func NewCountDownEvent() *CountDownEvent
func (*CountDownEvent) Await ¶
func (cde *CountDownEvent) Await()
func (*CountDownEvent) CountDown ¶
func (cde *CountDownEvent) CountDown()
func (*CountDownEvent) GetAttachment ¶
func (cde *CountDownEvent) GetAttachment() interface{}
func (*CountDownEvent) IncrementAndGet ¶
func (cde *CountDownEvent) IncrementAndGet() int64
func (*CountDownEvent) SetAttachment ¶
func (cde *CountDownEvent) SetAttachment(attachment interface{})
type Event ¶
type Event interface { // Topic of the event Name() string // The sequence number of the event Sequence() int64 }
Event interface
type EventCenter ¶
type EventCenter struct { Publishers *common.ConcurrentMap // <string:event_name, *Publisher > // contains filtered or unexported fields }
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
func (*Publisher) AddSubscriber ¶
func (p *Publisher) AddSubscriber(s Subscriber)
func (*Publisher) PublishEvent ¶
func (*Publisher) PublishEventNonBlock ¶
func (*Publisher) RemoveSubscriber ¶
func (p *Publisher) RemoveSubscriber(s Subscriber)
type Segment ¶
type Segment struct {
// contains filtered or unexported fields
}
func NewSegment ¶
func NewSegment(owner *SegmentList) *Segment
func (*Segment) IsReachEnd ¶
func (*Segment) RemoveFromFirst ¶
func (*Segment) RemoveFromFirstWhen ¶
func (*Segment) RemoveFromLastWhen ¶
type SegmentList ¶
type SegmentList struct {
// contains filtered or unexported fields
}
func NewSegmentList ¶
func NewSegmentList() *SegmentList
func (*SegmentList) Add ¶
func (sl *SegmentList) Add(e interface{})
func (*SegmentList) AddAll ¶
func (sl *SegmentList) AddAll(arr []interface{})
func (*SegmentList) Clear ¶
func (sl *SegmentList) Clear()
func (*SegmentList) Get ¶
func (sl *SegmentList) Get(index int32) interface{}
func (*SegmentList) GetFirst ¶
func (sl *SegmentList) GetFirst() *Segment
func (*SegmentList) GetLast ¶
func (sl *SegmentList) GetLast() *Segment
func (*SegmentList) IsEmpty ¶
func (sl *SegmentList) IsEmpty() bool
func (*SegmentList) PeekFirst ¶
func (sl *SegmentList) PeekFirst() interface{}
func (*SegmentList) PeekLast ¶
func (sl *SegmentList) PeekLast() interface{}
func (*SegmentList) RemoveFromFirst ¶
func (sl *SegmentList) RemoveFromFirst(toIndex int32)
func (*SegmentList) RemoveFromFirstWhen ¶
func (sl *SegmentList) RemoveFromFirstWhen(predicate func(v interface{}) bool)
func (*SegmentList) RemoveFromLastWhen ¶
func (sl *SegmentList) RemoveFromLastWhen(predicate func(v interface{}) bool)
func (*SegmentList) SegmentsSize ¶
func (sl *SegmentList) SegmentsSize() int32
func (*SegmentList) Size ¶
func (sl *SegmentList) Size() int32
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
func NewSetWithValues ¶
func NewSetWithValues(arr ...interface{}) *Set
func (*Set) AddAllWithSet ¶
func (*Set) RemoveAllWithSet ¶
func (*Set) RetainAllWithSet ¶
type Subscriber ¶
type SyncSet ¶
type SyncSet struct {
// contains filtered or unexported fields
}
func NewSyncSet ¶
func NewSyncSet() *SyncSet
type TreeMap ¶
type TreeMap struct { BinarySearchTree // contains filtered or unexported fields }
func NewTreeMap ¶
func (*TreeMap) ComputeIfAbsent ¶
func (tMap *TreeMap) ComputeIfAbsent(key interface{}, supplier func() interface{}) interface{}
func (*TreeMap) RangeEntry ¶
func (tMap *TreeMap) RangeEntry(consumer func(k, v interface{}))
func (*TreeMap) RangeLessThan ¶
func (tMap *TreeMap) RangeLessThan(key interface{}, consumer func(k, v interface{}))
Click to show internal directories.
Click to hide internal directories.