Documentation ¶
Index ¶
- Variables
- func AcquireErrorRsp() *rpc.ErrResponse
- func AcquireInsertReq() *rpc.InsertRequest
- func AcquireInsertRsp() *rpc.InsertResponse
- func AcquireRaftCMDRequest() *raftpb.RaftCMDRequest
- func AcquireRaftMessage() *raftpb.RaftMessage
- func AcquireSearchReq() *rpc.SearchRequest
- func AcquireSearchRsp() *rpc.SearchResponse
- func AcquireUpdateReq() *rpc.UpdateRequest
- func AcquireUpdateRsp() *rpc.UpdateResponse
- func DefaultTimeoutWheel() *goetty.TimeoutWheel
- func DiskStats(path string) (*disk.UsageStat, error)
- func ExecuteInParallel(q *Queue, fn func(interface{}))
- func GZIP(path string) error
- func GZIPTo(path string, dest string) error
- func MemStats() (*mem.VirtualMemoryStat, error)
- func PatchSaramaOffset(config *cluster.Config, committedOffset, committedIndex int64) error
- func PrintVersion()
- func ReleaseErrorRsp(value *rpc.ErrResponse)
- func ReleaseInsertReq(value *rpc.InsertRequest)
- func ReleaseInsertRsp(value *rpc.InsertResponse)
- func ReleaseRaftCMDRequest(value *raftpb.RaftCMDRequest)
- func ReleaseRaftMessage(value *raftpb.RaftMessage)
- func ReleaseSearchReq(value *rpc.SearchRequest)
- func ReleaseSearchRsp(value *rpc.SearchResponse)
- func ReleaseUpdateReq(value *rpc.UpdateRequest)
- func ReleaseUpdateRsp(value *rpc.UpdateResponse)
- func UnGZIP(file string, dest string) error
- type Queue
- func (q *Queue) Dispose() []interface{}
- func (q *Queue) Disposed() bool
- func (q *Queue) Empty() bool
- func (q *Queue) Get(number int64, items []interface{}) (int64, error)
- func (q *Queue) Len() int64
- func (q *Queue) Peek() (interface{}, error)
- func (q *Queue) Poll(number int64, items []interface{}, timeout time.Duration) (int64, error)
- func (q *Queue) Put(items ...interface{}) error
- func (q *Queue) PutOrUpdate(cmp func(interface{}, interface{}) bool, item interface{}) error
- type RingBuffer
- func (rb *RingBuffer) Cap() uint64
- func (rb *RingBuffer) Dispose()
- func (rb *RingBuffer) Get() (interface{}, error)
- func (rb *RingBuffer) IsDisposed() bool
- func (rb *RingBuffer) Len() uint64
- func (rb *RingBuffer) Offer(item interface{}) (bool, error)
- func (rb *RingBuffer) Poll(timeout time.Duration) (interface{}, error)
- func (rb *RingBuffer) Put(item interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDisposed is returned when an operation is performed on a disposed // queue. ErrDisposed = errors.New(`queue: disposed`) // ErrTimeout is returned when an applicable queue operation times out. ErrTimeout = errors.New(`queue: poll timed out`) // ErrEmptyQueue is returned when an non-applicable queue operation was called // due to the queue's empty item state ErrEmptyQueue = errors.New(`queue: empty queue`) )
var ( GitCommit = "" BuildTime = "" GoVersion = "" )
set on build time
Functions ¶
func AcquireErrorRsp ¶
func AcquireErrorRsp() *rpc.ErrResponse
AcquireErrorRsp returns a value from pool
func AcquireInsertReq ¶
func AcquireInsertReq() *rpc.InsertRequest
AcquireInsertReq returns a value from pool
func AcquireInsertRsp ¶
func AcquireInsertRsp() *rpc.InsertResponse
AcquireInsertRsp returns a value from pool
func AcquireRaftCMDRequest ¶
func AcquireRaftCMDRequest() *raftpb.RaftCMDRequest
AcquireRaftCMDRequest returns a raft cmd request from pool
func AcquireRaftMessage ¶
func AcquireRaftMessage() *raftpb.RaftMessage
AcquireRaftMessage returns a raft message from pool
func AcquireSearchReq ¶
func AcquireSearchReq() *rpc.SearchRequest
AcquireSearchReq returns a value from pool
func AcquireSearchRsp ¶
func AcquireSearchRsp() *rpc.SearchResponse
AcquireSearchRsp returns a value from pool
func AcquireUpdateReq ¶
func AcquireUpdateReq() *rpc.UpdateRequest
AcquireUpdateReq returns a value from pool
func AcquireUpdateRsp ¶
func AcquireUpdateRsp() *rpc.UpdateResponse
AcquireUpdateRsp returns a value from pool
func DefaultTimeoutWheel ¶
func DefaultTimeoutWheel() *goetty.TimeoutWheel
DefaultTimeoutWheel returns default timeout wheel
func ExecuteInParallel ¶
func ExecuteInParallel(q *Queue, fn func(interface{}))
ExecuteInParallel will (in parallel) call the provided function with each item in the queue until the queue is exhausted. When the queue is exhausted execution is complete and all goroutines will be killed. This means that the queue will be disposed so cannot be used again.
func MemStats ¶
func MemStats() (*mem.VirtualMemoryStat, error)
MemStats returns the mem usage stats
func PatchSaramaOffset ¶
PatchSaramaOffset add spec offset patch for sarama
func ReleaseErrorRsp ¶
func ReleaseErrorRsp(value *rpc.ErrResponse)
ReleaseErrorRsp returns a value to pool
func ReleaseInsertReq ¶
func ReleaseInsertReq(value *rpc.InsertRequest)
ReleaseInsertReq returns a value to pool
func ReleaseInsertRsp ¶
func ReleaseInsertRsp(value *rpc.InsertResponse)
ReleaseInsertRsp returns a value to pool
func ReleaseRaftCMDRequest ¶
func ReleaseRaftCMDRequest(value *raftpb.RaftCMDRequest)
ReleaseRaftCMDRequest returns a raft cmd request to pool
func ReleaseRaftMessage ¶
func ReleaseRaftMessage(value *raftpb.RaftMessage)
ReleaseRaftMessage returns a raft message to pool
func ReleaseSearchReq ¶
func ReleaseSearchReq(value *rpc.SearchRequest)
ReleaseSearchReq returns a value to pool
func ReleaseSearchRsp ¶
func ReleaseSearchRsp(value *rpc.SearchResponse)
ReleaseSearchRsp returns a value to pool
func ReleaseUpdateReq ¶
func ReleaseUpdateReq(value *rpc.UpdateRequest)
ReleaseUpdateReq returns a value to pool
func ReleaseUpdateRsp ¶
func ReleaseUpdateRsp(value *rpc.UpdateResponse)
ReleaseUpdateRsp returns a value to pool
Types ¶
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is the struct responsible for tracking the state of the queue.
func (*Queue) Dispose ¶
func (q *Queue) Dispose() []interface{}
Dispose will dispose of this queue and returns the items disposed. Any subsequent calls to Get or Put will return an error.
func (*Queue) Disposed ¶
Disposed returns a bool indicating if this queue has had disposed called on it.
func (*Queue) Get ¶
Get retrieves items from the queue. If there are some items in the queue, get will return a number UP TO the number passed in as a parameter. If no items are in the queue, this method will pause until items are added to the queue.
func (*Queue) Peek ¶
Peek returns a the first item in the queue by value without modifying the queue.
func (*Queue) Poll ¶
Poll retrieves items from the queue. If there are some items in the queue, Poll will return a number UP TO the number passed in as a parameter. If no items are in the queue, this method will pause until items are added to the queue or the provided timeout is reached. A non-positive timeout will block until items are added. If a timeout occurs, ErrTimeout is returned.
func (*Queue) PutOrUpdate ¶
PutOrUpdate will add the specified item to the queue, update it if exists
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer is a MPMC buffer that achieves threadsafety with CAS operations only. A put on full or get on empty call will block until an item is put or retrieved. Calling Dispose on the RingBuffer will unblock any blocked threads with an error. This buffer is similar to the buffer described here: http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue with some minor additions.
func NewRingBuffer ¶
func NewRingBuffer(size uint64) *RingBuffer
NewRingBuffer will allocate, initialize, and return a ring buffer with the specified size.
func (*RingBuffer) Cap ¶
func (rb *RingBuffer) Cap() uint64
Cap returns the capacity of this ring buffer.
func (*RingBuffer) Dispose ¶
func (rb *RingBuffer) Dispose()
Dispose will dispose of this queue and free any blocked threads in the Put and/or Get methods. Calling those methods on a disposed queue will return an error.
func (*RingBuffer) Get ¶
func (rb *RingBuffer) Get() (interface{}, error)
Get will return the next item in the queue. This call will block if the queue is empty. This call will unblock when an item is added to the queue or Dispose is called on the queue. An error will be returned if the queue is disposed.
func (*RingBuffer) IsDisposed ¶
func (rb *RingBuffer) IsDisposed() bool
IsDisposed will return a bool indicating if this queue has been disposed.
func (*RingBuffer) Len ¶
func (rb *RingBuffer) Len() uint64
Len returns the number of items in the queue.
func (*RingBuffer) Offer ¶
func (rb *RingBuffer) Offer(item interface{}) (bool, error)
Offer adds the provided item to the queue if there is space. If the queue is full, this call will return false. An error will be returned if the queue is disposed.
func (*RingBuffer) Poll ¶
func (rb *RingBuffer) Poll(timeout time.Duration) (interface{}, error)
Poll will return the next item in the queue. This call will block if the queue is empty. This call will unblock when an item is added to the queue, Dispose is called on the queue, or the timeout is reached. An error will be returned if the queue is disposed or a timeout occurs. A non-positive timeout will block indefinitely.
func (*RingBuffer) Put ¶
func (rb *RingBuffer) Put(item interface{}) error
Put adds the provided item to the queue. If the queue is full, this call will block until an item is added to the queue or Dispose is called on the queue. An error will be returned if the queue is disposed.