Skip to content

Instantly share code, notes, and snippets.

@trusch
Created April 16, 2019 09:48
Show Gist options
  • Save trusch/4ec3c9af79aff2747358701fc31c54ed to your computer and use it in GitHub Desktop.
Save trusch/4ec3c9af79aff2747358701fc31c54ed to your computer and use it in GitHub Desktop.
package queue
import (
"context"
"time"
)
type Task struct {
ID string
Payload []byte
Metadata map[string]interface{}
CreatedAt time.Time
StartedAt time.Time
FinishedAt time.Time
LastHeartbeat time.Time
}
type Manager interface {
Enqueue(ctx context.Context, queue string, task *Task) error
Dequeue(ctx context.Context, queue string) (*Task, error)
Heartbeat(ctx context.Context, queue, taskID string, metadata map[string]interface{}) error
Finish(ctx context.Context, queue, taskID string, metadata map[string]interface{}) error
Inspect(ctx context.Context, queue string, offset uint64) (chan *Task, error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment