Documentation
¶
Index ¶
- type DequeueParams
- type EnqueueParams
- type EnqueuedMessageEvent
- type JobStatus
- type Message
- type MessagesCh
- type Params
- type Queue
- type SqliteQueue
- func (q *SqliteQueue) Close() error
- func (q *SqliteQueue) Dequeue(params DequeueParams) (*Message, error)
- func (q *SqliteQueue) Done(id int64) error
- func (q *SqliteQueue) Enqueue(data any, params EnqueueParams) (int64, error)
- func (q *SqliteQueue) Fail(id int64) error
- func (q *SqliteQueue) Lock(messageID int64) (*Message, error)
- func (q *SqliteQueue) Prune() error
- func (q *SqliteQueue) Retry(id int64) error
- func (q *SqliteQueue) Size() (int, error)
- func (s *SqliteQueue) Subscribe(namespace string) (MessagesCh, error)
- func (q *SqliteQueue) Vacuum() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DequeueParams ¶
type DequeueParams struct {
// Namespace is the namespace to dequeue from
Namespace string
}
func (DequeueParams) Defaults ¶
func (p DequeueParams) Defaults() DequeueParams
type EnqueueParams ¶
type EnqueueParams struct {
// Namespace is the namespace to enqueue the job to
Namespace string
// ScheduleAfter is the number of seconds to wait before making the job available
// for consumption
ScheduleAfter time.Duration
// TTL is the number of seconds to keep the job around available for consumption
TTL time.Duration
}
EnqueueParams are passed into the Queue.Enqueue method
func (EnqueueParams) Defaults ¶
func (p EnqueueParams) Defaults() (EnqueueParams, error)
Defaults sets the default values for the EnqueueParams
type EnqueuedMessageEvent ¶
type MessagesCh ¶
type MessagesCh chan EnqueuedMessageEvent
type Params ¶
type Params struct {
// DB is the main link to the database, you can either pass this from outside
// or if left nil it will try to create it
DB *sql.DB
Clock clock.Clock
// DatabasePath is the path where the database sits (if no sql.DB is being passed)
DatabasePath string
// AutoVacuum automatically handles vaccuming the db, if this is not
// enabled you will have to take care of it by manually calling Queue.Vacuum
AutoVacuum bool
AutoVacuumInterval time.Duration
// AutoPrune deletes completed jobs
AutoPrune bool
AutoPruneInterval time.Duration
// DefaultTTL is the default time to live for a job
DefaultTTL time.Duration
}
Params are passed into the Queue and accept external user input
type Queue ¶
type Queue interface {
// EnqueueWithParams adds a new job to the Queue with custom parameters
Enqueue(data any, params EnqueueParams) (int64, error)
// Dequeue returns the next job in the Queue
Dequeue(params DequeueParams) (*Message, error)
// Done marks the job as done
Done(id int64) error
// Fail marks the job as failed
Fail(id int64) error
// Retry marks the message as ready to be consumed again
Retry(id int64) error
// Size returns the size of the queue
Size() (int, error)
// Lock provides direct access to lock the message.
// This is used mostly by the subscription mechanism.
Lock(messageID int64) (*Message, error)
// Subscribe returns a channel that will receive messages as they are enqueued
// this provides a simple way to implement pub/sub.
// Note that the jobs are not consumed from the queue, they are just sent to the
// channel as they are enqueued and if work needs to happen on them you'd have to lock
// them using the Lock(id) method.
Subscribe(namespace string) (MessagesCh, error)
// Prune deletes completed jobs
Prune() error
// Close clears the auto matically clean system and db file handles
Close() error
}
Queue describes the main interface of the queue system
type SqliteQueue ¶
type SqliteQueue struct {
// contains filtered or unexported fields
}
func (*SqliteQueue) Close ¶
func (q *SqliteQueue) Close() error
func (*SqliteQueue) Dequeue ¶
func (q *SqliteQueue) Dequeue(params DequeueParams) (*Message, error)
Dequeue
func (*SqliteQueue) Enqueue ¶
func (q *SqliteQueue) Enqueue(data any, params EnqueueParams) (int64, error)
Enqueue adds a new job to the Queue
func (*SqliteQueue) Prune ¶
func (q *SqliteQueue) Prune() error
func (*SqliteQueue) Retry ¶
func (q *SqliteQueue) Retry(id int64) error
Retry marks the message as ready to be consumed again
func (*SqliteQueue) Size ¶
func (q *SqliteQueue) Size() (int, error)
Retry marks the message as ready to be consumed again
func (*SqliteQueue) Subscribe ¶
func (s *SqliteQueue) Subscribe(namespace string) (MessagesCh, error)
func (*SqliteQueue) Vacuum ¶
func (q *SqliteQueue) Vacuum() error
Click to show internal directories.
Click to hide internal directories.
Tiny little queue on top of SQLite written in Go.