announcequeue

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Copyright (c) 2016-2019 Uber Technologies, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DisabledQueue

type DisabledQueue struct{}

DisabledQueue is a Queue which ignores all input and constantly returns that there are no torrents in the queue. Suitable for origin peers which want to disable announcing.

func Disabled

func Disabled() DisabledQueue

Disabled returns a new DisabledQueue.

func (DisabledQueue) Add

func (q DisabledQueue) Add(core.InfoHash)

Add noops.

func (DisabledQueue) Eject

func (q DisabledQueue) Eject(core.InfoHash)

Eject noops.

func (DisabledQueue) Next

func (q DisabledQueue) Next() (core.InfoHash, bool)

Next never returns a torrent.

func (DisabledQueue) Ready

func (q DisabledQueue) Ready(core.InfoHash)

Ready noops.

type Queue

type Queue interface {
	Next() (core.InfoHash, bool)
	Add(core.InfoHash)
	Ready(core.InfoHash)
	Eject(core.InfoHash)
}

Queue manages a queue of torrents waiting to announce.

type QueueImpl

type QueueImpl struct {
	// contains filtered or unexported fields
}

QueueImpl is the primary implementation of Queue. QueueImpl is not thread safe -- synchronization must be provided by clients.

func New

func New() *QueueImpl

New returns a new QueueImpl.

func (*QueueImpl) Add

func (q *QueueImpl) Add(h core.InfoHash)

Add adds a torrent to the back of the queue. Behavior is undefined if called twice on the same torrent.

func (*QueueImpl) Eject

func (q *QueueImpl) Eject(h core.InfoHash)

Eject immediately ejects h from the announce queue, preventing it from announcing further.

func (*QueueImpl) Next

func (q *QueueImpl) Next() (core.InfoHash, bool)

Next returns the next torrent ready to announce. After Next is called, the returned torrent will be marked as pending and will not be appear again in Next until Ready is called with said torrent. Second return value is false if no torrents are ready.

func (*QueueImpl) Ready

func (q *QueueImpl) Ready(h core.InfoHash)

Ready places a pending torrent back in the queue. Should be called once an announce response is received.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL