updater

package
v0.0.0-...-5e0ec4f Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: MIT, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeDir

func MakeDir(filename string) (dbdir string, err error)

func RenameFile

func RenameFile(fromName string, toName string) error

Types

type Config

type Config struct {
	Notifier       *Notifier // Holds all notification channels
	File           string
	Archive        string
	Closed         bool // Mark this db as closed.
	UpdateInterval time.Duration
	RetryInterval  time.Duration
	LastUpdated    time.Time // Last time the db was updated.

	Mu sync.RWMutex // Protects all the above.
	// contains filtered or unexported fields
}

func NewDefaultConfig

func NewDefaultConfig(UpdateInterval time.Duration, RetryInterval time.Duration, File string, Archive string, updateUrl string, cbk func() error) *Config

func (*Config) Close

func (c *Config) Close()

Close closes the database.

func (*Config) Date

func (c *Config) Date() time.Time

Date returns the UTC date the database file was last modified. If no database file has been opened the behaviour of Date is undefined.

func (*Config) ExtractTarGz

func (c *Config) ExtractTarGz(gzipStream io.Reader) (error, string)

func (*Config) ExtractZip

func (c *Config) ExtractZip() (error, string)

func (*Config) NotifyClose

func (c *Config) NotifyClose() <-chan struct{}

NotifyClose returns a channel that is closed when the database is closed.

func (*Config) NotifyError

func (c *Config) NotifyError() (errChan <-chan error)

NotifyError returns a channel that notifies when an error occurs while downloading or reloading a Config that points to a URL.

func (*Config) NotifyInfo

func (c *Config) NotifyInfo() <-chan string

NotifyInfo returns a channel that notifies informational messages while downloading or reloading.

func (*Config) NotifyOpen

func (c *Config) NotifyOpen() (filename <-chan string)

NotifyOpen returns a channel that notifies when a new database is loaded or reloaded. This can be used to monitor background updates when the Config points to a URL.

func (*Config) Open

func (c *Config) Open() error

Open creates and initializes a DB from a local file.

The database file is monitored by fsnotify and automatically reloads when the file is updated or overwritten.

func (*Config) OpenURL

func (c *Config) OpenURL() (*Config, error)

OpenURL creates and initializes a DB from a URL. It automatically downloads and updates the file in background, and keeps a local copy on $TMPDIR.

func (*Config) ProcessFile

func (c *Config) ProcessFile() (error, string)

func (*Config) SendError

func (c *Config) SendError(err error)

func (*Config) SendInfo

func (c *Config) SendInfo(message string)

type Notifier

type Notifier struct {
	Quit  chan struct{} // Stop the db auto-update and all active watch goroutines.
	Open  chan string   // Notify when a new db file is open.
	Error chan error    // Notify when an error occurs.
	Info  chan string   // Notify info actions for logging
}

Jump to

Keyboard shortcuts

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