Documentation ¶
Index ¶
- Variables
- type Handler
- type Query
- type Queue
- func (q *Queue) AddRequest(params RequestParams) (*openapi.PinStatus, error)
- func (q *Queue) Close() error
- func (q *Queue) GetRequest(group, id string) (*openapi.PinStatus, error)
- func (q *Queue) ListRequests(group string, query Query) ([]openapi.PinStatus, error)
- func (q *Queue) NewID(t time.Time) (string, error)
- func (q *Queue) RemoveRequest(group, id string) error
- func (q *Queue) ReplaceRequest(group, id string, pin openapi.Pin) (*openapi.PinStatus, error)
- type Request
- type RequestParams
Constants ¶
This section is empty.
Variables ¶
var ( // StartDelay is the time delay before the queue will process queued request on start. StartDelay = time.Second * 10 // MaxConcurrency is the maximum number of requests that will be handled concurrently. MaxConcurrency = 100 // ErrNotFound indicates the requested request was not found. ErrNotFound = errors.New("request not found") // ErrInProgress indicates the request is in progress and cannot be altered. ErrInProgress = errors.New("request in progress") )
Functions ¶
This section is empty.
Types ¶
type Handler ¶
Handler is called when a request moves from "queued" to "pinning". This separates the queue's job from the actual handling of a request, making the queue logic easier to test.
type Query ¶
type Query struct { Cids []string Name string Match openapi.TextMatchingStrategy Statuses []openapi.Status Before time.Time After time.Time Limit int Meta map[string]string }
Query is used to query for requests (a more typed version of openapi.Query).
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is a persistent worker-based task queue.
func NewQueue ¶
func NewQueue(store kt.TxnDatastoreExtended, handler Handler) (*Queue, error)
NewQueue returns a new Queue using handler to process requests.
func (*Queue) AddRequest ¶
func (q *Queue) AddRequest(params RequestParams) (*openapi.PinStatus, error)
AddRequest adds a new request to the queue. The new request will be handled immediately if workers are not busy.
func (*Queue) GetRequest ¶
GetRequest returns a request by group key and id.
func (*Queue) ListRequests ¶
ListRequests lists requests for a group key by applying a Query.
func (*Queue) RemoveRequest ¶
RemoveRequest removes a request. Note: In-progress ("pinning") requests cannot be removed.
type Request ¶
type Request struct { openapi.PinStatus Thread core.ID Key string Identity did.Token // Replace indicates openapi.PinStatus.Pin.Cid is marked for replacement. Replace bool // Remove indicates the request is marked for removal. Remove bool }
Request is a wrapper for openapi.PinStatus that is persisted to the datastore.