joncrlsn / dque

dque is a fast, embedded, durable queue for Go
MIT License
767 stars 46 forks source link

DQue should be an Interface #34

Open nfoerster opened 2 years ago

nfoerster commented 2 years ago

Although the current state works great, think about changing DQue as the return of New() to an interface. This makes it much easier for testing purposes. A dummy implementation of the interface would avoid any write/lock implications during testing.

type DQue interface {
  Close() error
  Enqueue(obj interface{}) error
  Dequeue() (interface{}, error)
  Peek() (interface{}, error)
  DequeueBlock() (interface{}, error)
  PeekBlock() (interface{}, error)
  Size() int
  SizeUnsafe() int
  SegmentNumbers() (int, int)
  Turbo() bool
  TurboOn() error
  TurboOff() error
  TurboSync() error
}