geoipupdate

package
v5.1.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0, MIT Imports: 17 Imported by: 0

Documentation

Overview

Package geoipupdate provides a library for using MaxMind's GeoIP Update service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client uses config data to initiate a download or update process for GeoIP databases.

func NewClient

func NewClient(config *Config) *Client

NewClient initialized a new Client struct.

func (*Client) Run

func (c *Client) Run(ctx context.Context) error

Run starts the download or update process.

type Config

type Config struct {
	// AccountID is the account ID.
	AccountID int
	// DatabaseDirectory is where database files are going to be
	// stored.
	DatabaseDirectory string
	// EditionIDs are the database editions to be updated.
	EditionIDs []string
	// LicenseKey is the license attached to the account.
	LicenseKey string
	// LockFile is the path of a lock file that ensures that only one
	// geoipupdate process can run at a time.
	LockFile string
	// PreserveFileTimes sets whether database modification times
	// are preserved across downloads.
	PreserveFileTimes bool
	// Parallelism defines the number of concurrent downloads that
	// can be triggered at the same time. It defaults to 1, which
	// wouldn't change the existing behaviour of downloading files
	// sequentially.
	Parallelism int
	// Proxy is host name or IP address of a proxy server.
	Proxy *url.URL
	// RetryFor is the retry timeout for HTTP requests. It defaults
	// to 5 minutes.
	RetryFor time.Duration
	// URL points to maxmind servers.
	URL string
	// Verbose turns on debug statements.
	Verbose bool
	// Output turns on sending the download/update result to stdout as JSON.
	Output bool
}

Config is a parsed configuration file.

func NewConfig

func NewConfig(
	path string,
	flagOptions ...Option,
) (*Config, error)

NewConfig parses the configuration file. flagOptions is provided to provide optional flag overrides to the config file.

type Option

type Option func(f *Config) error

Option is a function type that modifies a configuration object. It is used to define functions that override a config with values set as command line arguments.

func WithDatabaseDirectory

func WithDatabaseDirectory(dir string) Option

WithDatabaseDirectory returns an Option that sets the DatabaseDirectory value of a config.

func WithOutput added in v5.1.0

func WithOutput(val bool) Option

WithOutput returns an Option that sets the Output value of a config.

func WithParallelism

func WithParallelism(i int) Option

WithParallelism returns an Option that sets the Parallelism value of a config.

func WithVerbose

func WithVerbose(val bool) Option

WithVerbose returns an Option that sets the Verbose value of a config.

Directories

Path Synopsis
Package database provides an abstraction over getting and writing a database file.
Package database provides an abstraction over getting and writing a database file.
Package internal is none of your business
Package internal is none of your business
Package vars hold random vars, consts and defaults.
Package vars hold random vars, consts and defaults.

Jump to

Keyboard shortcuts

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