Skip to content

Diskqueue implement in Golang refer from NSQ diskqueue

Notifications You must be signed in to change notification settings

kkdai/diskqueue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Diskqueue: Disk storage Message Queue package refer from NSQ

GitHub license GoDoc Build Status

What is this "Disk Queue"

Diskqueue is a submodule of NSQ which to use Disk to store message queue.

Disclaimer

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.

Currently Features

  • Basic Queue handle
  • One messsage into single file

ToDo Features

  • 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)

Installation and Usage

Install

go get github.com/kkdai/diskqueue

Usage

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()
}

Inspired By

Project52

It is one of my project 52.

License

This package is licensed under MIT license. See LICENSE for details.

About

Diskqueue implement in Golang refer from NSQ diskqueue

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages