announcer

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ObjTypeAny int = iota
	ObjTypeGit
	ObjTypeRepoName
)
View Source
const (
	// KeyReannounceDur is the duration that passes streamer/streamer_test.go:630:between key re-announcement.
	KeyReannounceDur = 5 * time.Hour

	// ReannouncerInterval is the duration between each reannoucement process.
	ReannouncerInterval = 30 * time.Second
)

Variables

View Source
var ErrDelisted = fmt.Errorf("key delisted")

ErrDelisted indicates that a task failed to be announced because it was delisted

View Source
var MaxRetry = 3

MaxRetry is the number of times to try to reannounce a key

Functions

This section is empty.

Types

type Announcer

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

Announcer implements dht.Announcer. It provides the mechanism for announcing keys on the DHT. Announcement requests are queued up an concurrently executed by n workers. When an announcement fails, it is retried several times.

func New

func New(cfg *config.AppConfig, dht *kaddht.IpfsDHT, keepers core.Keepers) *Announcer

New creates an instance of Announcer

func (*Announcer) Announce

func (a *Announcer) Announce(objType int, repo string, key []byte, doneCB func(error)) bool

Announce queues an object to be announced. objType is the type of the object. repo is the name of the repository where the object can be found. key is the unique identifier of the object. doneCB is called after successful announcement Returns true if object has been successfully queued

func (*Announcer) Do

func (a *Announcer) Do(task *Task) (err error)

Do announces the key in the given task. After announcement, the key is (re)added to the announce list.

func (*Announcer) GetQueued

func (a *Announcer) GetQueued() map[string]struct{}

GetQueued returns the index containing tasks awaiting processing.

func (*Announcer) HasTask

func (a *Announcer) HasTask() bool

HasTask checks whether there are one or more unprocessed tasks.

func (*Announcer) IsRunning

func (a *Announcer) IsRunning() bool

IsRunning checks if the announcer is running.

func (*Announcer) NewSession

func (a *Announcer) NewSession() dht3.Session

NewSession creates an instance of Session

func (*Announcer) QueueSize

func (a *Announcer) QueueSize() int

QueueSize returns the size of the queue

func (*Announcer) Reannounce

func (a *Announcer) Reannounce()

Reannounce finds keys that need to be re-announced

func (*Announcer) RegisterChecker

func (a *Announcer) RegisterChecker(objType int, checker dht3.CheckFunc)

RegisterChecker allows external caller to register existence checker for a given object type. Only one checker per object type.

func (*Announcer) Start

func (a *Announcer) Start()

Start starts the workers. Panics if already started.

func (*Announcer) Stop

func (a *Announcer) Stop()

Stop stops the announcer

type Session

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

Session represents a multi-announcement session.

func NewSession

func NewSession(a dht3.Announcer) *Session

NewSession creates an instance of Session

func (*Session) Announce

func (s *Session) Announce(objType int, repo string, key []byte) bool

Announce an object

func (*Session) OnDone

func (s *Session) OnDone(cb func(errCount int))

OnDone calls the callback with the number of failed announcements in the session.

type Task

type Task struct {
	Type           int             // The type of object the key represents.
	RepoName       string          // The name of the repository where the object can be found
	Key            util.Bytes      // The unique object key
	CheckExistence bool            // Indicates that existence check should be performed on the key.
	Done           func(err error) // Done is called on success or failure
}

Task represents a key that needs to be announced.

func (*Task) GetID

func (t *Task) GetID() interface{}

Jump to

Keyboard shortcuts

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