All notable changes to this project will be documented in this file.
The format is based on "Keep a Changelog", and this project adheres to Semantic Versioning.
EnqueueContext
method is added toClient
.
- Fixed an error when user pass a duration less than 1s to
Unique
option
NewTask
takesOption
as variadic argument- Bumped minimum supported go version to 1.14 (i.e. go1.14 or higher is required).
Retention
option is added to allow user to specify task retention duration after completion.TaskID
option is added to allow user to specify task ID.ErrTaskIDConflict
sentinel error value is added.ResultWriter
type is added and provided throughTask.ResultWriter
method.TaskInfo
has new fieldsCompletedAt
,Result
andRetention
.
Client.SetDefaultOptions
is removed. UseNewTask
instead to pass default options for tasks.
- Updated
github.com/go-redis/redis
package to v8
IsFailure
config option is added to determine whether error returned from Handler counts as a failure.
- Scheduler methods are now thread-safe. It's now safe to call
Register
andUnregister
concurrently.
Client.Enqueue
no longer enqueues tasks with empty typename; Error message is returned.
- Changed
Queue
function to not to convert the provided queue name to lowercase. Queue names are now case-sensitive. QueueInfo.MemoryUsage
is now an approximate usage value.
- Fixed latency issue around memory usage (see hibiken#309).
- Changed to execute task recovering logic when server starts up; Previously it needed to wait for a minute for task recovering logic to exeucte.
- Fixed task recovering logic to execute every minute
- NewTask function now takes array of bytes as payload.
- Task
Type
andPayload
should be accessed by a method call. Server
API has changed. RenamedQuiet
toStop
. RenamedStop
toShutdown
. Note: As a result of this renaming, the behavior ofStop
has changed. Please update the exising code to callShutdown
where it used to callStop
.Scheduler
API has changed. RenamedStop
toShutdown
.- Requires redis v4.0+ for multiple field/value pair support
Client.Enqueue
now returnsTaskInfo
Inspector.RunTaskByKey
is replaced withInspector.RunTask
Inspector.DeleteTaskByKey
is replaced withInspector.DeleteTask
Inspector.ArchiveTaskByKey
is replaced withInspector.ArchiveTask
inspeq
package is removed. All types and functions from the package is moved toasynq
package.WorkerInfo
field names have changed.Inspector.CancelActiveTask
is renamed toInspector.CancelProcessing
- Free unique lock when task is deleted (hibiken#275).
- Fix bug in internal
RDB.memoryUsage
method.
DialTimeout
,ReadTimeout
, andWriteTimeout
options are added toRedisConnOpt
.
- Replace
KEYS
command withSCAN
as recommended by redis doc.
Unregister
method is added toScheduler
to remove a registered entry.
IMPORTATNT: All Inspector
related code are moved to subpackage "github.com/hibiken/asynq/inspeq"
Inspector
related code are moved to subpackage "github.com/hibken/asynq/inspeq".RedisConnOpt
interface has changed slightly. If you have been passingRedisClientOpt
,RedisFailoverClientOpt
, orRedisClusterClientOpt
as a pointer, update your code to pass as a value.ErrorMsg
field inRetryTask
andArchivedTask
was renamed toLastError
.
MaxRetry
,Retried
,LastError
fields were added to all task types returned fromInspector
.MemoryUsage
field was added toQueueStats
.DeleteAllPendingTasks
,ArchiveAllPendingTasks
were added toInspector
DeleteTaskByKey
andArchiveTaskByKey
now supports deleting/archivingPendingTask
.- asynq CLI now supports deleting/archiving pending tasks.
go.mod
file for CLI
IMPORTATNT: Please run asynq migrate
command to migrate from the previous versions.
- Renamed
DeadTask
toArchivedTask
. - Renamed the operation
Kill
toArchive
inInpsector
. - Print stack trace when Handler panics.
- Include a file name and a line number in the error message when recovering from a panic.
DefaultRetryDelayFunc
is now a public API, which can be used in the customRetryDelayFunc
.SkipRetry
error is added to be used as a return value fromHandler
.Servers
method is added toInspector
CancelActiveTask
method is added toInspector
.ListSchedulerEnqueueEvents
method is added toInspector
.SchedulerEntries
method is added toInspector
.DeleteQueue
method is added toInspector
.
- Fixed processor to wait for specified time duration before forcefully shutdown workers.
Scheduler
type is added to enable periodic tasks. See the godoc for its APIs and wiki for the getting-started guide.
- interface
Option
has changed. See the godoc for the new interface. This change would have no impact as long as you are using exported functions (e.g.MaxRetry
,Queue
, etc) to createOption
s.
Payload.String() string
method is addedPayload.MarshalJSON() ([]byte, error)
method is added
IMPORTANT: If you are upgrading from a previous version, please install the latest version of the CLI go get -u github.com/hibiken/asynq/tools/asynq
and run asynq migrate
command. No process should be writing to Redis while you run the migration command.
Previously, we called tasks that are ready to be processed "Enqueued tasks", and other tasks that are scheduled to be processed in the future "Scheduled tasks", etc. We changed the semantics of "Enqueue" slightly; All tasks that client pushes to Redis are Enqueued to a queue. Within a queue, tasks will transition from one state to another. Possible task states are:
Pending
: task is ready to be processed (previously called "Enqueued")Active
: tasks is currently being processed (previously called "InProgress")Scheduled
: task is scheduled to be processed in the futureRetry
: task failed to be processed and will be retried again in the futureDead
: task has exhausted all of its retries and stored for manual inspection purpose
These semantics change is reflected in the new Inspector
API and CLI commands.
Use ProcessIn
or ProcessAt
option to schedule a task instead of EnqueueIn
or EnqueueAt
.
Previously | v0.12.0 |
---|---|
client.EnqueueAt(t, task) |
client.Enqueue(task, asynq.ProcessAt(t)) |
client.EnqueueIn(d, task) |
client.Enqueue(task, asynq.ProcessIn(d)) |
All Inspector methods are scoped to a queue, and the methods take qname (string)
as the first argument.
EnqueuedTask
is renamed to PendingTask
and its corresponding methods.
InProgressTask
is renamed to ActiveTask
and its corresponding methods.
Command "Enqueue" is replaced by the verb "Run" (e.g. EnqueueAllScheduledTasks
--> RunAllScheduledTasks
)
CLI commands are restructured to use subcommands. Commands are organized into a few management commands:
To view details on any command, use asynq help <command> <subcommand>
.
asynq stats
asynq queue [ls inspect history rm pause unpause]
asynq task [ls cancel delete kill run delete-all kill-all run-all]
asynq server [ls]
RedisClusterClientOpt
is added to connect to Redis Cluster.Username
field is added to allRedisConnOpt
types in order to authenticate connection when Redis ACLs are used.
ProcessIn(d time.Duration) Option
andProcessAt(t time.Time) Option
are added to replaceEnqueueIn
andEnqueueAt
functionality.
Queues() ([]string, error)
method is added to get all queue names.ClusterKeySlot(qname string) (int64, error)
method is added to get queue's hash slot in Redis cluster.ClusterNodes(qname string) ([]ClusterNode, error)
method is added to get a list of Redis cluster nodes for the given queue.Close() error
method is added to close connection with redis.
GetQueueName(ctx context.Context) (string, bool)
helper is added to extract queue name from a context.
Inspector
type was added to monitor and mutate state of queues and tasks.HealthCheckFunc
andHealthCheckInterval
fields were added toConfig
to allow user to specify a callback function to check for broker connection.
- All tasks now requires timeout or deadline. By default, timeout is set to 30 mins.
- Tasks that exceed its deadline are automatically retried.
- Encoding schema for task message has changed. Please install the latest CLI and run
migrate
command if you have tasks enqueued with the previous version of asynq. - API of
(*Client).Enqueue
,(*Client).EnqueueIn
, and(*Client).EnqueueAt
has changed to return a*Result
. - API of
ErrorHandler
has changed. It now takes context as the first argument and removedretried
,maxRetry
from the argument list. UseGetRetryCount
and/orGetMaxRetry
to get the count values.
- Fixes issue of same tasks processed by more than one worker (hibiken#90).
- Fixes the JSON number overflow issue (hibiken#166).
- The
pause
andunpause
commands were added to the CLI. See README for the CLI for details.
GetTaskID
,GetRetryCount
, andGetMaxRetry
functions were added to extract task metadata from context.
Logger
interface has changed. Please see the godoc for the new interface.
LogLevel
type is added. Server's log level can be specified throughLogLevel
field inConfig
.
Close
method is added toClient
.
ParseRedisURI
helper function is added to create aRedisConnOpt
from a URI string.SetDefaultOptions
method is added toClient
.
Background
type is renamed toServer
.- To upgrade from the previous version, Update
NewBackground
toNewServer
and passConfig
by value. - CLI is renamed to
asynq
. - To upgrade the CLI to the latest version run
go get -u github.com/hibiken/tools/asynq
- The
ps
command in CLI is renamed toservers
Concurrency
defaults to the number of CPUs when unset or set to a negative value.
ShutdownTimeout
field is added toConfig
to speicfy timeout duration used during graceful shutdown.- New
Server
type exposesStart
,Stop
, andQuiet
as well asRun
.
- Fixed signal handling for windows.
- Support Go v1.13+, dropped support for go v1.12
Unique
option was added to allow client to enqueue a task only if it's unique within a certain time period.
Use
method was added toServeMux
to apply middlewares to all handlers.
Client
can optionally schedule task withasynq.Deadline(time)
to specify deadline for task's context. Default is no deadline.Logger
option was added to config, which allows user to specify the logger used by the background instance.
- Added
ServeMux
type to make it easy for users to implement Handler interface. ErrorHandler
type was added. Allow users to specify error handling function (e.g. Report error to error reporting service such as Honeybadger, Bugsnag, etc)
Client
API has changed. UseEnqueue
,EnqueueAt
andEnqueueIn
to enqueue and schedule tasks.
asynqmon workers
was added to list all running workers information
Handler
interface has changed.ProcessTask
method takes two argumentscontext.Context
and*asynq.Task
Queues
field inConfig
has change frommap[string]uint
tomap[string]int
Client
can optionally schedule task withasynq.Timeout(duration)
to specify timeout duration for task. Default is no timeout.asynqmon cancel [task id]
will send a cancelation signal to the goroutine processing the speicified task.
asynqmon ps
was added to list all background worker processes
- Fixed restoring unfinished tasks back to correct queues.
asynqmon ls
command is now paginated (default 30 tasks from first page)asynqmon ls enqueued:[queue name]
requires queue name to be specified
- More structured log messages
- Prevent spamming logs with a bunch of errors when Redis connection is lost
- Fixed and updated README doc
- NewTask constructor
Queues
option inConfig
to specify mutiple queues with priority levelClient
can schedule a task withasynq.Queue(name)
to specify which queue to useStrictPriority
option inConfig
to specify whether the priority should be followed strictlyRedisConnOpt
to abstract away redis client implementation- [CLI]
asynqmon rmq
command to remove queue
Client
andBackground
constructors takeRedisConnOpt
as their first argument.asynqmon stats
now shows the total of all enqueued tasks under "Enqueued"asynqmon stats
now shows each queue's task countasynqmon history
now doesn't take any arguments and shows data from the last 10 days by default (use--days
flag to change the number of days)- Task type is now immutable (i.e., Payload is read-only)
- Initial version of asynq package
- Initial version of asynqmon CLI