Documentation
¶
Index ¶
- Variables
- func Setup(ctx context.Context, db *sql.DB) error
- func SetupPostgres(ctx context.Context, db *sql.DB) error
- func SetupWithDialect(ctx context.Context, db *sql.DB, d dialect.Dialect) error
- type ID
- type Interface
- type Message
- type NewOpts
- type Queue
- func (q *Queue) Delete(ctx context.Context, id ID) error
- func (q *Queue) Extend(ctx context.Context, id ID, delay time.Duration) error
- func (q *Queue) MaxReceive() int
- func (q *Queue) MoveToDeadLetter(ctx context.Context, id ID, jobName, failureReason, errorMsg string) error
- func (q *Queue) Receive(ctx context.Context) (*Message, error)
- func (q *Queue) ReceiveAndWait(ctx context.Context, interval time.Duration) (*Message, error)
- func (q *Queue) Send(ctx context.Context, m Message) error
- func (q *Queue) SendAndGetID(ctx context.Context, m Message) (ID, error)
- func (q *Queue) SendTx(ctx context.Context, tx *sql.Tx, m Message) error
- func (q *Queue) Timeout() time.Duration
Constants ¶
This section is empty.
Variables ¶
View Source
var SchemaPostgres string
View Source
var SchemaSQLite string
Functions ¶
func SetupPostgres ¶ added in v0.2.3
SetupPostgres sets up the queue in a PostgreSQL database.
Types ¶
type Interface ¶
type Interface interface {
MaxReceive() int
Timeout() time.Duration
Send(context.Context, Message) error
SendTx(context.Context, *sql.Tx, Message) error
SendAndGetID(context.Context, Message) (ID, error)
Receive(context.Context) (*Message, error)
ReceiveAndWait(context.Context, time.Duration) (*Message, error)
Extend(context.Context, ID, time.Duration) error
Delete(context.Context, ID) error
MoveToDeadLetter(context.Context, ID, string, string, string) error
}
type NewOpts ¶
type NewOpts struct {
DB *sql.DB
MaxReceive int // Max receive count for messages before they cannot be received anymore.
Name string
Timeout time.Duration // Default timeout for messages before they can be re-received.
Logger logger.StandardLogger
Dialect dialect.Dialect // SQL dialect (SQLite or Postgres)
}
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
func New ¶
New Queue with the given options. Defaults if not given: - Logs are discarded. - Max receive count is 3. - Timeout is five seconds.
func (*Queue) MaxReceive ¶
func (*Queue) MoveToDeadLetter ¶
func (q *Queue) MoveToDeadLetter(ctx context.Context, id ID, jobName, failureReason, errorMsg string) error
MoveToDeadLetter moves a message from the main queue to the dead letter queue. This is used for jobs that fail permanently or exceed max retries.
func (*Queue) ReceiveAndWait ¶
ReceiveAndWait for a Message from the queue, polling at the given interval, until the context is cancelled. If the context is cancelled, the error will be non-nil. See context.Context.Err.
func (*Queue) SendAndGetID ¶
SendAndGetID is like Send, but also returns the message ID, which can be used to interact with the message without receiving it first.
Click to show internal directories.
Click to hide internal directories.