httpsync

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2019 License: GPL-3.0 Imports: 12 Imported by: 1

Documentation

Overview

Package httpsync implements methods for requesting and serving files via CAFS

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SyncFrom

func SyncFrom(ctx context.Context, storage cafs.FileStorage, client *http.Client, url, info string) (file cafs.File, err error)

Function SyncFrom uses an HTTP client to connect to some URL and download a fie into the given FileStorage.

Types

type FileHandler

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

Struct FileHandler implements the http.Handler interface and serves a file over HTTP. The protocol used matches with function SyncFrom. Create using the New... functions.

func NewFileHandlerFromFile

func NewFileHandlerFromFile(file cafs.File, perm shuffle.Permutation) *FileHandler

Function NewFileHandlerFromFile creates a FileHandler that serves chunks of a File.

func NewFileHandlerFromSyncInfo

func NewFileHandlerFromSyncInfo(syncinfo *remotesync.SyncInfo, storage cafs.FileStorage) *FileHandler

Function NewFileHandlerFromSyncInfo creates a FileHandler that serves chunks as specified in a FileInfo. It doesn't necessarily require all of the chunks to be present and will block waiting for a missing chunk to become available. As a specialty, a FileHander created using this function needs not be disposed.

func (*FileHandler) Dispose

func (handler *FileHandler) Dispose()

It is the owner's responsibility to correctly dispose of FileHandler instances.

func (*FileHandler) ServeHTTP

func (handler *FileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*FileHandler) WithPrinter

func (handler *FileHandler) WithPrinter(printer cafs.Printer) *FileHandler

Sets the FileHandler's log Printer.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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