fetcher

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicObjectFetcher

type BasicObjectFetcher struct {
	PackToRepoUnpacker plumbing.PackToRepoUnpacker
	// contains filtered or unexported fields
}

BasicObjectFetcher provides the ability to download objects from the DHT.

func NewFetcher

func NewFetcher(dht dht2.DHT, cfg *config.AppConfig) *BasicObjectFetcher

NewFetcher creates an instance of BasicObjectFetcher

func (*BasicObjectFetcher) FetchAsync

func (f *BasicObjectFetcher) FetchAsync(note types.PushNote, cb func(error))

Fetch adds a new task to the queue. cb will be called when the task has been processed.

func (*BasicObjectFetcher) IsQueueEmpty

func (f *BasicObjectFetcher) IsQueueEmpty() bool

IsQueueEmpty checks whether the task queue is empty

func (*BasicObjectFetcher) OnPackReceived

func (f *BasicObjectFetcher) OnPackReceived(cb func(string, io.ReadSeeker))

OnPackReceived registers a callback that is called each time an object's packfile is received

func (*BasicObjectFetcher) Operation

func (f *BasicObjectFetcher) Operation(task *Task) error

Operation attempts to fetch objects of the pushed references, one reference at a time and will immediate return error if on failure. For each object fetched, the resulting packfile decoded into the repository. Therefore, on error, objects of successfully fetched references will remain in the repository to be garbage collected by the pruner.

func (*BasicObjectFetcher) QueueSize

func (f *BasicObjectFetcher) QueueSize() int

QueueSize returns the size of the queue

func (*BasicObjectFetcher) Start

func (f *BasicObjectFetcher) Start()

Start starts processing tasks in the queue. It does not block. Panics if already started

func (*BasicObjectFetcher) Stop

func (f *BasicObjectFetcher) Stop()

Stop stops the fetcher service

type ObjectFetcher

type ObjectFetcher interface {
	// FetchAsync adds a new task to the queue and returns immediately.
	// cb will be called when the task has been processed.
	FetchAsync(note types.PushNote, cb func(err error))

	// QueueSize returns the size of the queue
	QueueSize() int

	// OnPackReceived registers a callback that is called each time a packfile
	// of an object is fetched
	OnPackReceived(cb func(hash string, packfile io.ReadSeeker))

	// Start starts the fetcher service
	Start()

	// Stops the fetcher service
	Stop()
}

ObjectFetcher describes a module for fetching git objects from a given DHT service.

type ObjectFetcherService

type ObjectFetcherService interface {

	// FetchAsync adds a new task to the queue.
	// cb will be called when the task has been processed.
	FetchAsync(note types.PushNote, cb func(err error))

	// OnPackReceived registers a callback that is called each time a packfile
	// of an object is fetched
	OnPackReceived(cb func(hash string, packfile io.ReadSeeker))
}

ObjectFetcherService is like ObjectFetcher but exposes limited methods.

type Task

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

Task represents a fetch task

func NewTask

func NewTask(note types.PushNote, resCb func(err error)) *Task

NewTask creates an instance of Task

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