Documentation
¶
Index ¶
Constants ¶
const ( FtpProv = iota FsProv )
Constants for picking DataProvider implementations.
const TmpFileLoc = "/tmp/vehicledata.zip"
TmpFileLoc contains the temporary location of the ZIP file before unzipping.
Variables ¶
This section is empty.
Functions ¶
func ProvTypeString ¶
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) 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) 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.