vlv

package module
v0.0.0-...-0a184f4 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

README

vlv

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDriveClient

func NewDriveClient(ctx context.Context, confdir string) (*http.Client, error)

NewDriveClient creates a new client for Google Drive.

func NewServer

func NewServer(addr string, d *Dispatcher, coll *docstore.Collection) *http.Server

NewServer creates a new server.

func OpenCollection

func OpenCollection(ctx context.Context, config *StoreConfig) (*docstore.Collection, error)

OpenCollection opens the collection of tasks.

Types

type Config

type Config struct {
	Address string       `toml:"addr"`
	Store   *StoreConfig `toml:"store"`

	// Rate represents a byte for token bucket rate per second.
	Rate float64 `toml:"rate"`

	// Capacity represents a byte for token bucket capacity.
	Capacity int64 `toml:"capacity"`
}

Config represents a configuration for vlv.

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig loads a file as Config.

type Dispatcher

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

Dispatcher represents a dispatcher.

func NewDispatcher

func NewDispatcher(client *http.Client, coll *docstore.Collection, rate float64, capacity int64) *Dispatcher

NewDispatcher creates a new dispatcher.

func (*Dispatcher) Start

func (d *Dispatcher) Start(ctx context.Context)

Start starts to dispatch.

func (*Dispatcher) Status

func (d *Dispatcher) Status() *DispatcherStatus

type DispatcherStatus

type DispatcherStatus struct {
	*TaskStatus
	Shut bool `json:"shut"`
}

type StoreConfig

type StoreConfig struct {
	URL       string `toml:"url"`
	Localfile string `toml:"localfile"`
}

StoreConfig represents a configuration for store.

type Task

type Task struct {
	Filename    string   `json:"filename" docstore:"filename"`
	Description string   `json:"description" docstore:"description"`
	Parents     []string `json:"parents" docstore:"parents"`
	MimeType    string   `json:"mimeType" docstore:"mimeType"`
	CreateTime  int64    `json:"createTime" docstore:"createTime"`

	DocstoreRevision interface{}
	// contains filtered or unexported fields
}

Task represents a task to upload.

func TaskFromRequest

func TaskFromRequest(r *http.Request) (*Task, error)

TaskFromRequest creates a new Task from http.Request.

func (*Task) CreatedAt

func (t *Task) CreatedAt() time.Time

CreatedAt returns when the task was created.

func (*Task) Do

func (t *Task) Do(ctx context.Context, client *http.Client, rate float64, capacity int64) error

Do uploads a file of the task.

func (*Task) Status

func (t *Task) Status() *TaskStatus

type TaskStatus

type TaskStatus struct {
	Filename string `json:"filename"`
	Progress string `json:"progress"`
	Current  int64  `json:"current_bytes"`
	Total    int64  `json:"total_bytes"`
}

Directories

Path Synopsis
cmd
vlv

Jump to

Keyboard shortcuts

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