dataprovider

package
v0.0.0-...-161b4be Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FtpProv = iota
	FsProv
)

Constants for picking DataProvider implementations.

View Source
const TmpFileLoc = "/tmp/vehicledata.zip"

TmpFileLoc contains the temporary location of the ZIP file before unzipping.

Variables

This section is empty.

Functions

func ProvTypeString

func ProvTypeString(ptype int) string

ProvTypeString returns the string representation of the provider type.

Types

type DataProvider

type DataProvider interface {
	Open() error
	Close() error
	CheckForLatest(string) (string, error)
	Provide(string) (io.ReadCloser, error)
}

DataProvider is the interface for implementations that fetches files for Autobot to parse.

func NewProvider

func NewProvider(ptype int, config config.ProviderConfig) DataProvider

NewProvider returns a new provider of the requested type (implementation).

type FileProvider

type FileProvider struct{}

FileProvider is a data provider that supports local files.

func NewFileProvider

func NewFileProvider() *FileProvider

NewFileProvider returns a new FileProvider.

func (*FileProvider) CheckForLatest

func (prov *FileProvider) CheckForLatest(fname string) (string, error)

CheckForLatest simply checks if the file is readable.

func (*FileProvider) Close

func (prov *FileProvider) Close() error

Close does nothing.

func (*FileProvider) Open

func (prov *FileProvider) Open() error

Open does nothing for FileProvider.

func (*FileProvider) Provide

func (prov *FileProvider) Provide(fname string) (rc io.ReadCloser, err error)

Provide makes a local file available to autobot.

type FtpProvider

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

FtpProvider is a data provider that supports file retrieval via FTP.

func NewFtpProvider

func NewFtpProvider(conf config.FtpConfig) *FtpProvider

NewFtpProvider returns a new FtpProvider.

func (*FtpProvider) CheckForLatest

func (prov *FtpProvider) CheckForLatest(fname string) (string, error)

CheckForLatest checks if there are any new files in the same format as the one given and returns the filename of the latest one if possible. Otherwise, the original filename is returned.

func (*FtpProvider) Close

func (prov *FtpProvider) Close() error

Close closes the FTP connection.

func (*FtpProvider) Open

func (prov *FtpProvider) Open() error

Open establishes the FTP connection.

func (*FtpProvider) Provide

func (prov *FtpProvider) Provide(fname string) (io.ReadCloser, error)

Provide make an FTP file available to autobot by downloading it.

Jump to

Keyboard shortcuts

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