Documentation
¶
Index ¶
- type BasicTaskQueue
- func (q *BasicTaskQueue) Add(tasks ...any) error
- func (q *BasicTaskQueue) Clear() error
- func (q *BasicTaskQueue) Get(index int64) (string, error)
- func (q *BasicTaskQueue) Has(value string) bool
- func (q *BasicTaskQueue) Pop() *string
- func (q *BasicTaskQueue) Remove(task any) error
- func (q *BasicTaskQueue) RemoveIndex(index int64) error
- func (q *BasicTaskQueue) Size() uint64
- type JSONTaskQueue
- func (q *JSONTaskQueue) Add(tasks ...any) error
- func (q *JSONTaskQueue) Clear() error
- func (q *JSONTaskQueue) Get(index int64, target any) error
- func (q *JSONTaskQueue) Has(value any) bool
- func (q *JSONTaskQueue) Pop(value any) error
- func (q *JSONTaskQueue) PopBytes() ([]byte, error)
- func (q *JSONTaskQueue) Remove(task any) error
- func (q *JSONTaskQueue) RemoveIndex(index int64) error
- func (q *JSONTaskQueue) Size() uint64
- type Option
- func WithContext(ctx context.Context) Option
- func WithHost(host string) Option
- func WithNoRetry() Option
- func WithPassword(password string) Option
- func WithTLSConfig(tlsConfig *tls.Config) Option
- func WithTimeout(timeout time.Duration) Option
- func WithURI(uri string) Option
- func WithUsername(username string) Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BasicTaskQueue ¶
type BasicTaskQueue struct {
Name string
Redis redis.UniversalClient
// contains filtered or unexported fields
}
BasicTaskQueue implements a FIFO task queue of string values.
func NewBasic ¶
func NewBasic(name string, option ...Option) (*BasicTaskQueue, error)
NewBasic creates a new BasicTaskQueue instance.
func (*BasicTaskQueue) Add ¶
func (q *BasicTaskQueue) Add(tasks ...any) error
Add adds any number of tasks to the queue in order. Items provided will be marshaled to JSON.
func (*BasicTaskQueue) Clear ¶
func (q *BasicTaskQueue) Clear() error
Clear removes all tasks from the queue.
func (*BasicTaskQueue) Get ¶ added in v0.0.5
func (q *BasicTaskQueue) Get(index int64) (string, error)
Get retrieves an item from the queue based on its index.
func (*BasicTaskQueue) Has ¶ added in v0.0.6
func (q *BasicTaskQueue) Has(value string) bool
Has determines if a queue has an given task.
func (*BasicTaskQueue) Pop ¶
func (q *BasicTaskQueue) Pop() *string
Pop removes and returns the first task from the queue. If the queue is empty, the return value will be nil.
func (*BasicTaskQueue) Remove ¶
func (q *BasicTaskQueue) Remove(task any) error
Remove removes a task from the queue.
func (*BasicTaskQueue) RemoveIndex ¶ added in v0.0.5
func (q *BasicTaskQueue) RemoveIndex(index int64) error
func (*BasicTaskQueue) Size ¶
func (q *BasicTaskQueue) Size() uint64
Size returns the number of items in the queue.
type JSONTaskQueue ¶
type JSONTaskQueue struct {
// Name represents the Redis key.
Name string
// Redis is the underlying Redis instance.
Redis redis.UniversalClient
// contains filtered or unexported fields
}
JSONTaskQueue implements a FIFO task queue with any JSON-able value as the value.
func NewJSON ¶
func NewJSON(name string, option ...Option) (*JSONTaskQueue, error)
NewJSON creates a new JSONTaskQueue instance.
func (*JSONTaskQueue) Add ¶
func (q *JSONTaskQueue) Add(tasks ...any) error
Add adds any number of tasks to the queue in order. Items provided will be marshaled to JSON.
func (*JSONTaskQueue) Clear ¶
func (q *JSONTaskQueue) Clear() error
Clear removes all tasks from the queue.
func (*JSONTaskQueue) Get ¶ added in v0.0.5
func (q *JSONTaskQueue) Get(index int64, target any) error
func (*JSONTaskQueue) Has ¶ added in v0.0.6
func (q *JSONTaskQueue) Has(value any) bool
Has determines if a queue has an given task.
func (*JSONTaskQueue) Pop ¶
func (q *JSONTaskQueue) Pop(value any) error
Pop removes the first task from the queue and unmarshals the value.
func (*JSONTaskQueue) PopBytes ¶ added in v0.0.4
func (q *JSONTaskQueue) PopBytes() ([]byte, error)
func (*JSONTaskQueue) Remove ¶
func (q *JSONTaskQueue) Remove(task any) error
Remove removes a task from the queue.
func (*JSONTaskQueue) RemoveIndex ¶ added in v0.0.5
func (q *JSONTaskQueue) RemoveIndex(index int64) error
func (*JSONTaskQueue) Size ¶
func (q *JSONTaskQueue) Size() uint64
Size returns the number of items in the queue.
type Option ¶
type Option func(*Options)
func WithContext ¶
WithContext sets the Redis context object.
func WithNoRetry ¶ added in v0.0.4
func WithNoRetry() Option
WithNoRetry enables or disables task retry, which re-adds the task back to the queue if an error occurs while retrieving it.
func WithPassword ¶
WithPassword sets the password to use when authenticating to Redis.
func WithTLSConfig ¶
WithTLSConfig sets the TLS configuration of the Redis instance.
func WithTimeout ¶
WithTimeout sets the Redis read/write timeout.
func WithUsername ¶
WithUsername sets the username to use when authenticating to Redis.