Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var FIFOCompare = func(a, b *QueueTask) bool {
return a.created.Before(b.created)
}
FIFOCompare is a basic task comparator that returns tasks in the order created.
View Source
var PriorityCompare = func(a, b *QueueTask) bool { if a.Target == b.Target && a.Priority != b.Priority { return a.Priority > b.Priority } return FIFOCompare(a, b) }
PriorityCompare respects the target peer's task priority. For tasks involving different peers, the oldest task is prioritized.
Functions ¶
func WrapCompare ¶
func WrapCompare(f QueueTaskComparator) func(a, b pq.Elem) bool
WrapCompare wraps a QueueTask comparison function so it can be used as comparison for a priority queue
Types ¶
type Data ¶ added in v0.2.0
type Data interface{}
Data is used by the client to associate extra information with a Task
type QueueTask ¶ added in v0.2.0
QueueTask contains a Task, and also some bookkeeping information. It is used internally by the PeerTracker to keep track of tasks.
func NewQueueTask ¶ added in v0.2.0
NewQueueTask creates a new QueueTask from the given Task.
type QueueTaskComparator ¶ added in v0.6.0
type Task ¶
type Task struct { // Topic for the task Topic Topic // Priority of the task Priority int // The size of the task // - peers with most active work are deprioritized // - peers with most pending work are prioritized Work int // Arbitrary data associated with this Task by the client Data Data }
Task is a single task to be executed in Priority order.
Click to show internal directories.
Click to hide internal directories.