Documentation ¶
Index ¶
- type Option
- func IgnoreFreezing(ignoreFreezing bool) Option
- func MaxOutstandingWorkPerPeer(count int) Option
- func OnPeerAddedHook(onPeerAddedHook func(p peer.ID)) Option
- func OnPeerRemovedHook(onPeerRemovedHook func(p peer.ID)) Option
- func PeerComparator(pc peertracker.PeerComparator) Option
- func TaskComparator(tc peertask.QueueTaskComparator) Option
- func TaskMerger(tmfp peertracker.TaskMerger) Option
- type PeerTaskQueue
- func (ptq *PeerTaskQueue) Clear(p peer.ID)
- func (ptq *PeerTaskQueue) FullThaw()
- func (ptq *PeerTaskQueue) Options(options ...Option) Option
- func (ptq *PeerTaskQueue) PeerTopics(p peer.ID) *peertracker.PeerTrackerTopics
- func (ptq *PeerTaskQueue) PopTasks(targetMinWork int) (peer.ID, []*peertask.Task, int)
- func (ptq *PeerTaskQueue) PushTasks(to peer.ID, tasks ...peertask.Task)
- func (ptq *PeerTaskQueue) PushTasksTruncated(n uint, to peer.ID, tasks ...peertask.Task)
- func (ptq *PeerTaskQueue) Remove(topic peertask.Topic, p peer.ID)
- func (ptq *PeerTaskQueue) Stats() *PeerTaskQueueStats
- func (ptq *PeerTaskQueue) TasksDone(to peer.ID, tasks ...*peertask.Task)
- func (ptq *PeerTaskQueue) ThawRound()
- type PeerTaskQueueStats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*PeerTaskQueue) Option
Option is a function that configures the peer task queue
func IgnoreFreezing ¶
IgnoreFreezing is an option that can make the task queue ignore freezing and unfreezing
func MaxOutstandingWorkPerPeer ¶
MaxOutstandingWorkPerPeer is an option that specifies how many tasks a peer can have outstanding with the same Topic as an existing Topic.
func OnPeerAddedHook ¶
OnPeerAddedHook adds a hook function that gets called whenever the ptq adds a new peer
func OnPeerRemovedHook ¶
OnPeerRemovedHook adds a hook function that gets called whenever the ptq adds a new peer
func PeerComparator ¶
func PeerComparator(pc peertracker.PeerComparator) Option
PeerComparator is an option that specifies custom peer prioritization logic.
func TaskComparator ¶
func TaskComparator(tc peertask.QueueTaskComparator) Option
TaskComparator is an option that specifies custom task prioritization logic.
func TaskMerger ¶
func TaskMerger(tmfp peertracker.TaskMerger) Option
TaskMerger is an option that specifies merge behaviour when pushing a task with the same Topic as an existing Topic.
type PeerTaskQueue ¶
type PeerTaskQueue struct {
// contains filtered or unexported fields
}
PeerTaskQueue is a prioritized list of tasks to be executed on peers. Tasks are added to the queue, then popped off alternately between peers (roughly) to execute the block with the highest priority, or otherwise the one added first if priorities are equal.
func (*PeerTaskQueue) Clear ¶
func (ptq *PeerTaskQueue) Clear(p peer.ID)
Clear fully remove a peer from the task queue.
func (*PeerTaskQueue) FullThaw ¶
func (ptq *PeerTaskQueue) FullThaw()
FullThaw completely thaws all peers in the queue so they can execute tasks.
func (*PeerTaskQueue) Options ¶
func (ptq *PeerTaskQueue) Options(options ...Option) Option
Options uses configuration functions to configure the peer task queue. It returns an Option that can be called to reverse the changes.
func (*PeerTaskQueue) PeerTopics ¶
func (ptq *PeerTaskQueue) PeerTopics(p peer.ID) *peertracker.PeerTrackerTopics
PeerTopics returns all topics running on a specific peer
func (*PeerTaskQueue) PopTasks ¶
PopTasks finds the peer with the highest priority and pops as many tasks off the peer's queue as necessary to cover targetMinWork, in priority order. If there are not enough tasks to cover targetMinWork it just returns whatever is in the peer's queue.
- Peers with the most "active" work are deprioritized. This heuristic is for fairness, we try to keep all peers "busy".
- Peers with the most "pending" work are prioritized. This heuristic is so that peers with a lot to do get asked for work first.
The third response argument is pending work: the amount of work in the queue for this peer.
func (*PeerTaskQueue) PushTasks ¶
func (ptq *PeerTaskQueue) PushTasks(to peer.ID, tasks ...peertask.Task)
PushTasks adds a new group of tasks for the given peer to the queue
func (*PeerTaskQueue) PushTasksTruncated ¶
PushTasksTruncated is like PushTasks but it will not grow that peers's queue beyond n. When truncation happen we will keep older tasks in the queue to avoid some infinite tasks rotations if we are continously receiving work faster than we process it.
func (*PeerTaskQueue) Remove ¶
func (ptq *PeerTaskQueue) Remove(topic peertask.Topic, p peer.ID)
Remove removes a task from the queue.
func (*PeerTaskQueue) Stats ¶
func (ptq *PeerTaskQueue) Stats() *PeerTaskQueueStats
Stats returns current stats about the task queue.
func (*PeerTaskQueue) TasksDone ¶
func (ptq *PeerTaskQueue) TasksDone(to peer.ID, tasks ...*peertask.Task)
TasksDone is called to indicate that the given tasks have completed for the given peer
func (*PeerTaskQueue) ThawRound ¶
func (ptq *PeerTaskQueue) ThawRound()
ThawRound unthaws peers incrementally, so that those have been frozen the least become unfrozen and able to execute tasks first.
type PeerTaskQueueStats ¶
PeerTaskQueueStats captures current stats about the task queue.