broker

package
v0.0.0-...-50051f8 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoUSBMounts = errors.New("no suitable USB devices")

Functions

func Close

func Close(b *Broker)

func Delete

func Delete(b *Broker, bucket string, before time.Time)

func DeleteExchange

func DeleteExchange(b *Broker, exchangeId string) error

func FindStringInSlice

func FindStringInSlice(slice []string, val string) (int, bool)

func GetExchange

func GetExchange(b *Broker, exchangeId string) ([]byte, error)

func ListExchanges

func ListExchanges(b *Broker) map[string]string

func NoExchangeConnected

func NoExchangeConnected(b *Broker) bool

func OnUpdate

func OnUpdate(b *Broker) chan Update

func Pull

func Pull(b *Broker, bucket string, localFiles []string, folder string) int

func Push

func Push(b *Broker, bucket string, localFiles []string) []string

func SetExchange

func SetExchange(b *Broker, exchangeId string, config []byte) error

Types

type Broker

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

func Open

func Open(exchangesFolder, stagingFolder, accessId, secret string) (*Broker, error)

type Exchange

type Exchange interface {
	/** Connect to the broker using local as exchangesFolder where download/upload files are */
	Connect(onUpdate chan Update) error
	Disconnect()

	Status() Status

	/** List lists all the entries at the provided bucket */
	List(bucket string) ([]os.FileInfo, error)

	/** Push the file to the bucket */
	Put(bucket string, info os.FileInfo, reader io.Reader) error

	/** Get a file content from the bucket */
	Get(bucket string, info os.FileInfo, writer io.Writer) error

	/** Purge all files older than the specified timestamp*/
	Delete(bucket string, info os.FileInfo) error

	String() string
}

func OpenFTP

func OpenFTP(config []byte) (Exchange, error)

func OpenS3

func OpenS3(config []byte) (Exchange, error)

func OpenUSB

func OpenUSB(config []byte) (Exchange, error)

type FTPConfig

type FTPConfig struct {
	URL      string `json:"url" yaml:"url"`
	Username string `json:"username" yaml:"username"`
	Password string `json:"password" yaml:"password"`
	Timeout  int    `json:"timeout" yaml:"timeout"`
}

type FTPExchange

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

func (*FTPExchange) Connect

func (exchange *FTPExchange) Connect(_ chan Update) error

func (*FTPExchange) Delete

func (exchange *FTPExchange) Delete(bucket string, info os.FileInfo) error

func (*FTPExchange) Disconnect

func (exchange *FTPExchange) Disconnect()

func (*FTPExchange) Get

func (exchange *FTPExchange) Get(bucket string, info os.FileInfo, dest io.Writer) error

func (*FTPExchange) List

func (exchange *FTPExchange) List(bucket string) ([]os.FileInfo, error)

func (*FTPExchange) Put

func (exchange *FTPExchange) Put(bucket string, info os.FileInfo, source io.Reader) error

func (*FTPExchange) Status

func (exchange *FTPExchange) Status() Status

func (*FTPExchange) String

func (exchange *FTPExchange) String() string

type FileInfo

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

func (FileInfo) IsDir

func (f FileInfo) IsDir() bool

func (FileInfo) ModTime

func (f FileInfo) ModTime() time.Time

func (FileInfo) Mode

func (f FileInfo) Mode() os.FileMode

func (FileInfo) Name

func (f FileInfo) Name() string

func (FileInfo) Size

func (f FileInfo) Size() int64

func (FileInfo) Sys

func (f FileInfo) Sys() interface{}

type S3Config

type S3Config struct {
	Name      string `json:"name" yaml:"name"`
	Endpoint  string `json:"endpoint" yaml:"endpoint"`
	Bucket    string `json:"bucket" yaml:"bucket"`
	AccessKey string `json:"accessKey" yaml:"accessKey"`
	Secret    string `json:"secret" yaml:"secret"`
	UseSSL    bool   `json:"useSSL" yaml:"useSSL"`
	Location  string `json:"location" yaml:"location"`
}

type S3Exchange

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

func (*S3Exchange) Connect

func (exchange *S3Exchange) Connect(onUpdate chan Update) error

func (*S3Exchange) Delete

func (exchange *S3Exchange) Delete(bucket string, info os.FileInfo) error

func (*S3Exchange) Disconnect

func (exchange *S3Exchange) Disconnect()

func (*S3Exchange) Get

func (exchange *S3Exchange) Get(bucket string, info os.FileInfo, dest io.Writer) error

func (*S3Exchange) ID

func (exchange *S3Exchange) ID() string
func RemoveS3Secret(configs ...S3Config) {
	for i := range configs {
		configs[i].Secret = ""
	}
}

func (*S3Exchange) List

func (exchange *S3Exchange) List(bucket string) ([]os.FileInfo, error)

func (*S3Exchange) Name

func (exchange *S3Exchange) Name() string

func (*S3Exchange) Put

func (exchange *S3Exchange) Put(bucket string, info os.FileInfo, source io.Reader) error

func (*S3Exchange) Status

func (exchange *S3Exchange) Status() Status

func (*S3Exchange) String

func (exchange *S3Exchange) String() string

type Status

type Status struct {
	Err         error
	SupportList bool
}

type USBConfig

type USBConfig struct {
	Name   string `json:"name" yaml:"name"`
	Folder string `json:"folder" yaml:"folder"`
}

type USBExchange

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

func (*USBExchange) Connect

func (exchange *USBExchange) Connect(_ chan Update) error

func (*USBExchange) Delete

func (exchange *USBExchange) Delete(bucket string, info os.FileInfo) error

func (*USBExchange) Disconnect

func (exchange *USBExchange) Disconnect()

func (*USBExchange) Get

func (exchange *USBExchange) Get(bucket string, info os.FileInfo, writer io.Writer) error

func (*USBExchange) ID

func (exchange *USBExchange) ID() string

func (*USBExchange) List

func (exchange *USBExchange) List(bucket string) ([]os.FileInfo, error)

func (*USBExchange) Name

func (exchange *USBExchange) Name() string

func (*USBExchange) Put

func (exchange *USBExchange) Put(bucket string, info os.FileInfo, reader io.Reader) error

func (*USBExchange) Status

func (exchange *USBExchange) Status() Status

func (*USBExchange) String

func (exchange *USBExchange) String() string

type Update

type Update struct {
	Exchange Exchange
	Bucket   string
	Info     os.FileInfo
	Reader   io.Reader
}

Jump to

Keyboard shortcuts

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