diff --git a/internal/base/base.go b/internal/base/base.go index bb31b7b..2ea0450 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -181,6 +181,12 @@ type TaskMessage struct { // ErrorMsg holds the error message from the last failure. ErrorMsg string + // Time of last failure in Unix time, + // the number of seconds elapsed since January 1, 1970 UTC. + // + // Use zero to indicate no last failure + LastFailedAt int64 + // Timeout specifies timeout in seconds. // If task processing doesn't complete within the timeout, the task will be retried // if retry count is remaining. Otherwise it will be moved to the archive. @@ -208,16 +214,17 @@ func EncodeMessage(msg *TaskMessage) ([]byte, error) { return nil, fmt.Errorf("cannot encode nil message") } return proto.Marshal(&pb.TaskMessage{ - Type: msg.Type, - Payload: msg.Payload, - Id: msg.ID.String(), - Queue: msg.Queue, - Retry: int32(msg.Retry), - Retried: int32(msg.Retried), - ErrorMsg: msg.ErrorMsg, - Timeout: msg.Timeout, - Deadline: msg.Deadline, - UniqueKey: msg.UniqueKey, + Type: msg.Type, + Payload: msg.Payload, + Id: msg.ID.String(), + Queue: msg.Queue, + Retry: int32(msg.Retry), + Retried: int32(msg.Retried), + ErrorMsg: msg.ErrorMsg, + LastFailedAt: msg.LastFailedAt, + Timeout: msg.Timeout, + Deadline: msg.Deadline, + UniqueKey: msg.UniqueKey, }) } @@ -228,16 +235,17 @@ func DecodeMessage(data []byte) (*TaskMessage, error) { return nil, err } return &TaskMessage{ - Type: pbmsg.GetType(), - Payload: pbmsg.GetPayload(), - ID: uuid.MustParse(pbmsg.GetId()), - Queue: pbmsg.GetQueue(), - Retry: int(pbmsg.GetRetry()), - Retried: int(pbmsg.GetRetried()), - ErrorMsg: pbmsg.GetErrorMsg(), - Timeout: pbmsg.GetTimeout(), - Deadline: pbmsg.GetDeadline(), - UniqueKey: pbmsg.GetUniqueKey(), + Type: pbmsg.GetType(), + Payload: pbmsg.GetPayload(), + ID: uuid.MustParse(pbmsg.GetId()), + Queue: pbmsg.GetQueue(), + Retry: int(pbmsg.GetRetry()), + Retried: int(pbmsg.GetRetried()), + ErrorMsg: pbmsg.GetErrorMsg(), + LastFailedAt: pbmsg.GetLastFailedAt(), + Timeout: pbmsg.GetTimeout(), + Deadline: pbmsg.GetDeadline(), + UniqueKey: pbmsg.GetUniqueKey(), }, nil } diff --git a/internal/proto/asynq.pb.go b/internal/proto/asynq.pb.go index fba1820..d2cab0d 100644 --- a/internal/proto/asynq.pb.go +++ b/internal/proto/asynq.pb.go @@ -1,3 +1,7 @@ +// Copyright 2020 Kentaro Hibino. All rights reserved. +// Use of this source code is governed by a MIT license +// that can be found in the LICENSE file. + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.25.0 @@ -26,20 +30,40 @@ const ( // of the legacy proto package is being used. const _ = proto.ProtoPackageIsVersion4 +// TaskMessage is the internal representation of a task with additional +// metadata fields. type TaskMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` - Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` - Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` - Queue string `protobuf:"bytes,4,opt,name=queue,proto3" json:"queue,omitempty"` - Retry int32 `protobuf:"varint,5,opt,name=retry,proto3" json:"retry,omitempty"` - Retried int32 `protobuf:"varint,6,opt,name=retried,proto3" json:"retried,omitempty"` - ErrorMsg string `protobuf:"bytes,7,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"` - Timeout int64 `protobuf:"varint,8,opt,name=timeout,proto3" json:"timeout,omitempty"` - Deadline int64 `protobuf:"varint,9,opt,name=deadline,proto3" json:"deadline,omitempty"` + // Type indicates the kind of the task to be performed. + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + // Payload holds data needed to process the task. + Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` + // Unique identifier for the task. + Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` + // Name of the queue to which this task belongs. + Queue string `protobuf:"bytes,4,opt,name=queue,proto3" json:"queue,omitempty"` + // Max number of retries for this task. + Retry int32 `protobuf:"varint,5,opt,name=retry,proto3" json:"retry,omitempty"` + // Number of times this task has been retried so far. + Retried int32 `protobuf:"varint,6,opt,name=retried,proto3" json:"retried,omitempty"` + // Error message from the last failure. + ErrorMsg string `protobuf:"bytes,7,opt,name=error_msg,json=errorMsg,proto3" json:"error_msg,omitempty"` + // Time of last failure in Unix time, + // the number of seconds elapsed since January 1, 1970 UTC. + // Use zero to indicate no last failure. + LastFailedAt int64 `protobuf:"varint,11,opt,name=last_failed_at,json=lastFailedAt,proto3" json:"last_failed_at,omitempty"` + // Timeout specifies timeout in seconds. + // Use zero to indicate no timeout. + Timeout int64 `protobuf:"varint,8,opt,name=timeout,proto3" json:"timeout,omitempty"` + // Deadline specifies the deadline for the task in Unix time, + // the number of seconds elapsed since January 1, 1970 UTC. + // Use zero to indicate no deadline. + Deadline int64 `protobuf:"varint,9,opt,name=deadline,proto3" json:"deadline,omitempty"` + // UniqueKey holds the redis key used for uniqueness lock for this task. + // Empty string indicates that no uniqueness lock was used. UniqueKey string `protobuf:"bytes,10,opt,name=unique_key,json=uniqueKey,proto3" json:"unique_key,omitempty"` } @@ -124,6 +148,13 @@ func (x *TaskMessage) GetErrorMsg() string { return "" } +func (x *TaskMessage) GetLastFailedAt() int64 { + if x != nil { + return x.LastFailedAt + } + return 0 +} + func (x *TaskMessage) GetTimeout() int64 { if x != nil { return x.Timeout @@ -151,15 +182,27 @@ type ServerInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` - Pid int32 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid,omitempty"` - ServerId string `protobuf:"bytes,3,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` - Concurrency int32 `protobuf:"varint,4,opt,name=concurrency,proto3" json:"concurrency,omitempty"` - Queues map[string]int32 `protobuf:"bytes,5,rep,name=queues,proto3" json:"queues,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` - StrictPriority bool `protobuf:"varint,6,opt,name=strict_priority,json=strictPriority,proto3" json:"strict_priority,omitempty"` - Status string `protobuf:"bytes,7,opt,name=status,proto3" json:"status,omitempty"` - StartTime *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` - ActiveWorkerCount int32 `protobuf:"varint,9,opt,name=active_worker_count,json=activeWorkerCount,proto3" json:"active_worker_count,omitempty"` + // Host machine the server is running on. + Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + // PID of the server process. + Pid int32 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid,omitempty"` + // Unique identifier for this server. + ServerId string `protobuf:"bytes,3,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` + // Maximum number of concurrency this server will use. + Concurrency int32 `protobuf:"varint,4,opt,name=concurrency,proto3" json:"concurrency,omitempty"` + // List of queue names with their priorities. + // The server will consume tasks from the queues and prioritize + // queues with higher priority numbers. + Queues map[string]int32 `protobuf:"bytes,5,rep,name=queues,proto3" json:"queues,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` + // If set, the server will always consume tasks from a queue with higher + // priority. + StrictPriority bool `protobuf:"varint,6,opt,name=strict_priority,json=strictPriority,proto3" json:"strict_priority,omitempty"` + // Status indicates the status of the server. + Status string `protobuf:"bytes,7,opt,name=status,proto3" json:"status,omitempty"` + // Time this server was started. + StartTime *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` + // Number of workers currently processing tasks. + ActiveWorkerCount int32 `protobuf:"varint,9,opt,name=active_worker_count,json=activeWorkerCount,proto3" json:"active_worker_count,omitempty"` } func (x *ServerInfo) Reset() { @@ -263,15 +306,25 @@ type WorkerInfo struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` - Pid int32 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid,omitempty"` - ServerId string `protobuf:"bytes,3,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` - TaskId string `protobuf:"bytes,4,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` - TaskType string `protobuf:"bytes,5,opt,name=task_type,json=taskType,proto3" json:"task_type,omitempty"` - TaskPayload []byte `protobuf:"bytes,6,opt,name=task_payload,json=taskPayload,proto3" json:"task_payload,omitempty"` - Queue string `protobuf:"bytes,7,opt,name=queue,proto3" json:"queue,omitempty"` - StartTime *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` - Deadline *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=deadline,proto3" json:"deadline,omitempty"` + // Host matchine this worker is running on. + Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + // PID of the process in which this worker is running. + Pid int32 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid,omitempty"` + // ID of the server in which this worker is running. + ServerId string `protobuf:"bytes,3,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` + // ID of the task this worker is processing. + TaskId string `protobuf:"bytes,4,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` + // Type of the task this worker is processing. + TaskType string `protobuf:"bytes,5,opt,name=task_type,json=taskType,proto3" json:"task_type,omitempty"` + // Payload of the task this worker is processing. + TaskPayload []byte `protobuf:"bytes,6,opt,name=task_payload,json=taskPayload,proto3" json:"task_payload,omitempty"` + // Name of the queue the task the worker is processing belongs. + Queue string `protobuf:"bytes,7,opt,name=queue,proto3" json:"queue,omitempty"` + // Time this worker started processing the task. + StartTime *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty"` + // Deadline by which the worker needs to complete processing + // the task. If worker exceeds the deadline, the task will fail. + Deadline *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=deadline,proto3" json:"deadline,omitempty"` } func (x *WorkerInfo) Reset() { @@ -369,7 +422,8 @@ func (x *WorkerInfo) GetDeadline() *timestamppb.Timestamp { return nil } -// SchedulerEntry holds information about a periodic task registered with a scheduler. +// SchedulerEntry holds information about a periodic task registered +// with a scheduler. type SchedulerEntry struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -473,7 +527,8 @@ func (x *SchedulerEntry) GetPrevEnqueueTime() *timestamppb.Timestamp { return nil } -// SchedulerEnqueueEvent holds information about an enqueue event by a scheduler. +// SchedulerEnqueueEvent holds information about an enqueue event +// by a scheduler. type SchedulerEnqueueEvent struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -534,35 +589,37 @@ func (x *SchedulerEnqueueEvent) GetEnqueueTime() *timestamppb.Timestamp { var File_asynq_proto protoreflect.FileDescriptor var file_asynq_proto_rawDesc = []byte{ - 0x0a, 0x0b, 0x61, 0x73, 0x79, 0x6e, 0x71, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x74, - 0x75, 0x74, 0x6f, 0x72, 0x69, 0x61, 0x6c, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x83, 0x02, 0x0a, 0x0b, 0x54, 0x61, 0x73, - 0x6b, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, - 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x75, 0x65, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, - 0x72, 0x65, 0x74, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x65, 0x74, - 0x72, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x64, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x07, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x09, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, - 0x65, 0x6f, 0x75, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, - 0x6f, 0x75, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x12, - 0x1d, 0x0a, 0x0a, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x0a, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4b, 0x65, 0x79, 0x22, 0x92, - 0x03, 0x0a, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, - 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, - 0x74, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, - 0x70, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, - 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x63, 0x79, 0x12, 0x38, 0x0a, 0x06, 0x71, 0x75, 0x65, 0x75, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x74, 0x75, 0x74, 0x6f, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x53, 0x65, + 0x0a, 0x0b, 0x61, 0x73, 0x79, 0x6e, 0x71, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x61, + 0x73, 0x79, 0x6e, 0x71, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa9, 0x02, 0x0a, 0x0b, 0x54, 0x61, 0x73, 0x6b, 0x4d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x79, + 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x75, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x74, + 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x72, 0x65, 0x74, 0x72, 0x79, 0x12, + 0x18, 0x0a, 0x07, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x07, 0x72, 0x65, 0x74, 0x72, 0x69, 0x65, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x66, + 0x61, 0x69, 0x6c, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, + 0x6c, 0x61, 0x73, 0x74, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, 0x41, 0x74, 0x12, 0x18, 0x0a, 0x07, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, + 0x6e, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x64, 0x65, 0x61, 0x64, 0x6c, 0x69, + 0x6e, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x5f, 0x6b, 0x65, 0x79, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x4b, 0x65, + 0x79, 0x22, 0x8f, 0x03, 0x0a, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x68, 0x6f, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x03, 0x70, 0x69, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x63, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x35, 0x0a, 0x06, 0x71, 0x75, 0x65, 0x75, 0x65, 0x73, 0x18, + 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x61, 0x73, 0x79, 0x6e, 0x71, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x71, 0x75, 0x65, 0x75, 0x65, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x5f, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, @@ -644,22 +701,22 @@ func file_asynq_proto_rawDescGZIP() []byte { var file_asynq_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_asynq_proto_goTypes = []interface{}{ - (*TaskMessage)(nil), // 0: tutorial.TaskMessage - (*ServerInfo)(nil), // 1: tutorial.ServerInfo - (*WorkerInfo)(nil), // 2: tutorial.WorkerInfo - (*SchedulerEntry)(nil), // 3: tutorial.SchedulerEntry - (*SchedulerEnqueueEvent)(nil), // 4: tutorial.SchedulerEnqueueEvent - nil, // 5: tutorial.ServerInfo.QueuesEntry + (*TaskMessage)(nil), // 0: asynq.TaskMessage + (*ServerInfo)(nil), // 1: asynq.ServerInfo + (*WorkerInfo)(nil), // 2: asynq.WorkerInfo + (*SchedulerEntry)(nil), // 3: asynq.SchedulerEntry + (*SchedulerEnqueueEvent)(nil), // 4: asynq.SchedulerEnqueueEvent + nil, // 5: asynq.ServerInfo.QueuesEntry (*timestamppb.Timestamp)(nil), // 6: google.protobuf.Timestamp } var file_asynq_proto_depIdxs = []int32{ - 5, // 0: tutorial.ServerInfo.queues:type_name -> tutorial.ServerInfo.QueuesEntry - 6, // 1: tutorial.ServerInfo.start_time:type_name -> google.protobuf.Timestamp - 6, // 2: tutorial.WorkerInfo.start_time:type_name -> google.protobuf.Timestamp - 6, // 3: tutorial.WorkerInfo.deadline:type_name -> google.protobuf.Timestamp - 6, // 4: tutorial.SchedulerEntry.next_enqueue_time:type_name -> google.protobuf.Timestamp - 6, // 5: tutorial.SchedulerEntry.prev_enqueue_time:type_name -> google.protobuf.Timestamp - 6, // 6: tutorial.SchedulerEnqueueEvent.enqueue_time:type_name -> google.protobuf.Timestamp + 5, // 0: asynq.ServerInfo.queues:type_name -> asynq.ServerInfo.QueuesEntry + 6, // 1: asynq.ServerInfo.start_time:type_name -> google.protobuf.Timestamp + 6, // 2: asynq.WorkerInfo.start_time:type_name -> google.protobuf.Timestamp + 6, // 3: asynq.WorkerInfo.deadline:type_name -> google.protobuf.Timestamp + 6, // 4: asynq.SchedulerEntry.next_enqueue_time:type_name -> google.protobuf.Timestamp + 6, // 5: asynq.SchedulerEntry.prev_enqueue_time:type_name -> google.protobuf.Timestamp + 6, // 6: asynq.SchedulerEnqueueEvent.enqueue_time:type_name -> google.protobuf.Timestamp 7, // [7:7] is the sub-list for method output_type 7, // [7:7] is the sub-list for method input_type 7, // [7:7] is the sub-list for extension type_name diff --git a/internal/proto/asynq.proto b/internal/proto/asynq.proto index 788f43d..3d6d611 100644 --- a/internal/proto/asynq.proto +++ b/internal/proto/asynq.proto @@ -33,6 +33,11 @@ message TaskMessage { // Error message from the last failure. string error_msg = 7; + // Time of last failure in Unix time, + // the number of seconds elapsed since January 1, 1970 UTC. + // Use zero to indicate no last failure. + int64 last_failed_at = 11; + // Timeout specifies timeout in seconds. // Use zero to indicate no timeout. int64 timeout = 8; @@ -45,6 +50,7 @@ message TaskMessage { // UniqueKey holds the redis key used for uniqueness lock for this task. // Empty string indicates that no uniqueness lock was used. string unique_key = 10; + }; // ServerInfo holds information about a running server.