Documentation
¶
Index ¶
- Constants
- Variables
- type Announcer
- func (a *Announcer) Announce(objType int, repo string, key []byte, doneCB func(error)) bool
- func (a *Announcer) Do(task *Task) (err error)
- func (a *Announcer) GetQueued() map[string]struct{}
- func (a *Announcer) HasTask() bool
- func (a *Announcer) IsRunning() bool
- func (a *Announcer) NewSession() dht3.Session
- func (a *Announcer) QueueSize() int
- func (a *Announcer) Reannounce()
- func (a *Announcer) RegisterChecker(objType int, checker dht3.CheckFunc)
- func (a *Announcer) Start()
- func (a *Announcer) Stop()
- type Session
- type Task
Constants ¶
const ( ObjTypeAny int = iota ObjTypeGit ObjTypeRepoName )
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 ¶
var ErrDelisted = fmt.Errorf("key delisted")
ErrDelisted indicates that a task failed to be announced because it was delisted
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 (*Announcer) Announce ¶
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 ¶
Do announces the key in the given task. After announcement, the key is (re)added to the announce list.
func (*Announcer) NewSession ¶
NewSession creates an instance of Session
func (*Announcer) Reannounce ¶
func (a *Announcer) Reannounce()
Reannounce finds keys that need to be re-announced
func (*Announcer) RegisterChecker ¶
RegisterChecker allows external caller to register existence checker for a given object type. Only one checker per object type.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a multi-announcement session.
func NewSession ¶
NewSession creates an instance of 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.