geoipupdate

package
v6.0.0-...-75421ee Latest Latest
Warning

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

Go to latest
Published: Jul 23, 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 {
	GetReader func() (database.Reader, error)
	// 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
	// contains filtered or unexported fields
}

Config is a parsed configuration file.

func NewConfig

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

NewConfig creates a new configuration and populates it based on an optional config file pointed to by an option set with WithConfigFile, then by various environment variables, and then finally by flag overrides provided by flagOptions. Values from the later override the former.

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 WithConfigFile

func WithConfigFile(file string) Option

WithConfigFile returns an Option that sets the configuration file to be used.

func WithDatabaseDirectory

func WithDatabaseDirectory(dir string) Option

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

func WithOutput

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 provides internal structures.
Package internal provides internal structures.
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