q

package module
v0.0.0-...-4b6a87e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2025 License: Apache-2.0 Imports: 12 Imported by: 1

README

Q

GoDoc

Q is a simple yet robust persistent message/task queue implemented in Go.

Features

  • Message Confirmation & Retry: Messages remain in queue until explicitly confirmed by consumers
  • Message Persistence: Reliable storage of messages to prevent data loss
  • Priority Queue: Support for message prioritization to handle urgent tasks first
  • Simple API: Easy to integrate and use
  • High Performance: Optimized for speed and efficiency
  • Zero Dependencies: Standalone implementation with no external requirements

Safety Guarantees

Messages in Q are handled with strong safety guarantees:

  • Messages persist until explicitly confirmed by consumers
  • Unconfirmed messages are automatically recycled back to the queue
  • No message loss even in case of crashes or failures
  • Priority levels are preserved during message recycling and recovery

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QServer

type QServer struct {
	// contains filtered or unexported fields
}

func NewQServer

func NewQServer(path string) (*QServer, error)

func (*QServer) Close

func (qs *QServer) Close()

func (*QServer) CreateTaskHandler

func (qs *QServer) CreateTaskHandler(w http.ResponseWriter, r *http.Request)

创建任务

func (*QServer) GetNextTaskHandler

func (qs *QServer) GetNextTaskHandler(w http.ResponseWriter, r *http.Request)

获取下一个任务预览

func (*QServer) GetQueueStatusHandler

func (qs *QServer) GetQueueStatusHandler(w http.ResponseWriter, r *http.Request)

获取队列状态

func (*QServer) GetTaskHandler

func (qs *QServer) GetTaskHandler(w http.ResponseWriter, r *http.Request)

获取任务

func (*QServer) UpdateTaskStatusHandler

func (qs *QServer) UpdateTaskStatusHandler(w http.ResponseWriter, r *http.Request)

更新任务状态

type Queue

type Queue struct {
	Path string `json:"path"`
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue(path string) (*Queue, error)

func NewQueueWithRetryLimit

func NewQueueWithRetryLimit(path string, limit int) (*Queue, error)

func (*Queue) Close

func (q *Queue) Close()

func (*Queue) Confirm

func (q *Queue) Confirm(key string) error

func (*Queue) Dequeue

func (q *Queue) Dequeue(timeout int64) (string, string, error)

func (*Queue) DequeueWithPreviousRetryCount

func (q *Queue) DequeueWithPreviousRetryCount(timeout int64) (string, string, int, error)

DequeueWithPreviousRetryCount removes and returns the next item in the queue along with the number of times it has been previously retried. If a timeout is specified, the item is added to the running queue.

func (*Queue) Drop

func (q *Queue) Drop()

func (*Queue) Enqueue

func (q *Queue) Enqueue(data string) error

func (*Queue) EnqueueWithPriority

func (q *Queue) EnqueueWithPriority(data string, priority uint8) error

func (*Queue) Length

func (q *Queue) Length() uint64

func (*Queue) Peek

func (q *Queue) Peek() (string, error)

func (*Queue) Status

func (q *Queue) Status() map[string]interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL