fetch

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogHttpResponse

func LogHttpResponse(resp *http.Response) string

func WaitTimeout

func WaitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool

WaitTimeout does a Wait on a sync.WaitGroup object but with a specified timeout. Returns true if the wait completed without timing out, false otherwise.

Types

type FetchTask

type FetchTask struct {
	Sha1 string
	Dest string
	// contains filtered or unexported fields
}

func (*FetchTask) Do

func (t *FetchTask) Do(ctx context.Context) (interface{}, error)

func (*FetchTask) OriginUrl

func (t *FetchTask) OriginUrl() string

func (*FetchTask) String

func (t *FetchTask) String() string

type FileBackendRequest

type FileBackendRequest struct {
	SHA1 string `json:"sha1"`
	Name string `json:"name"`
}

type FileBackendResponse

type FileBackendResponse struct {
	Url string `json:"url"`
}

type FilerBackend

type FilerBackend struct {
	Url       string
	UserAgent string
	// contains filtered or unexported fields
}

func NewFilerBackend

func NewFilerBackend(url string, ua string) *FilerBackend

func (*FilerBackend) RegisterFile

func (fb *FilerBackend) RegisterFile(ctx context.Context, sha1 string) (string, error)

type Task

type Task interface {
	Do(context.Context) (interface{}, error)
}

type TaskFactory

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

func NewTaskFactory

func NewTaskFactory() *TaskFactory

func (*TaskFactory) Make

func (f *TaskFactory) Make(sha1 string, dest string) *FetchTask

type TaskListener

type TaskListener interface {
	OnTaskEnqueue(Task)
	OnTaskRun(int, Task)
	OnTaskComplete(int, Task, interface{}, error)
}

type TaskQueue

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

func NewTaskQueue

func NewTaskQueue(workers int) *TaskQueue

func (*TaskQueue) AddListener

func (q *TaskQueue) AddListener(l TaskListener)

func (*TaskQueue) Close

func (q *TaskQueue) Close()

func (*TaskQueue) Enqueue

func (q *TaskQueue) Enqueue(task Task, timeout time.Duration) error

func (*TaskQueue) Size

func (q *TaskQueue) Size() int

Jump to

Keyboard shortcuts

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