Diskqueue is a submodule of NSQ which to use Disk to store message queue.
This is a going project, during I learn the program about NSQ. Until all ToDo item done, please use this under your own risk.
If you really need disk queue, please use NSQ: Diskqueue source code in your production consideration.
- Basic Queue handle
- One messsage into single file
- Seek handle
- One file store not only one message
- Seek write/read handle
- Gracefully handle for file R/W
- Message size validation (min/max message size)
go get github.com/kkdai/diskqueue
Following is sample code:
package main
import (
"fmt"
"github.com/kkdai/diskqueue"
)
func main() {
//Create a disk queue, please note the path must exist
dq := NewDiskqueue("workqueue", "./test")
//First put data
err = dq.Put([]byte("00"))
//Second data put
err = dq.Put([]byte("111"))
//Read data from queue, it is unbuffered channel
data := <-dq.ReadChan()
//Close this queue
dq.Close()
}
It is one of my project 52.
This package is licensed under MIT license. See LICENSE for details.