Documentation ¶
Index ¶
- Constants
- Variables
- func Compress(files []*os.File, dest string) error
- func Start()
- 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) Put(item interface{}) error
Constants ¶
const LOGFILE_PRIFIX = "logmover_"
Variables ¶
var ErrDisposed = errors.New(`queue: disposed`)
disposed error
Functions ¶
Types ¶
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) 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.