Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct { ID string `json:"id"` Task *Task `json:"task"` ScheduledTime time.Time `json:"scheduled_time"` CompletedChannel chan *TaskResponse `json:"-"` Ctx context.Context `json:"-"` CreatedAt time.Time `json:"created_at"` Status string `json:"status"` }
func NewRequest ¶
NewRequest creates a new job request with a single task.
func (*Request) IsCanceled ¶
IsCanceled checks if the job is canceled
func (*Request) MarkCanceled ¶
func (r *Request) MarkCanceled()
MarkCanceled updates the job's status to "canceled"
func (*Request) MarkComplete ¶
func (r *Request) MarkComplete(resp *TaskResponse)
MarkComplete sets the status of the request to "completed" and notifies via the channel.
type Task ¶
type Task struct { ID string // Unique ID for the task Callback Callback `json:"-"` // Exclude this field from marshaling Timeout time.Duration RetryCount int }
Represents a task to be executed.
func (*Task) MarshalJSON ¶
MarshalJSON is a custom marshaler for Task that excludes the Callback function.
func (*Task) UnmarshalJSON ¶
UnmarshalJSON is a custom unmarshaler for Task.
func (*Task) WithMilliSecondTimeout ¶
Set timeout in milliseconds for a task.
func (*Task) WithSecondTimeout ¶
Set timeout in seconds for a task.
type TaskResponse ¶
type TaskResponse struct { Data interface{} Error error }
Response structure for a task execution.
Click to show internal directories.
Click to hide internal directories.