ipread

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 26 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIpParseFailed = errors.New("failed to parse geo ip")
	ErrIpNotFound    = errors.New("ip not found")
)

Functions

func NewProviderRefreshModule added in v0.15.5

func NewProviderRefreshModule(name string, settings RefreshSettings) kernel.ModuleFactory

func ProvideMemoryProvider

func ProvideMemoryProvider(name string) *memoryProvider

func ProvideReader added in v0.15.5

func ProvideReader(ctx context.Context, config cfg.Config, logger log.Logger, name string) (*reader, error)

func RefreshModuleFactory added in v0.15.5

func RefreshModuleFactory(ctx context.Context, config cfg.Config, logger log.Logger) (map[string]kernel.ModuleFactory, error)

Types

type GeoCity

type GeoCity struct {
	City        string `json:"city"`
	CountryCode string `json:"countryCode"`
	Ip          string `json:"ip"`
	TimeZone    string `json:"timeZone"`
}

type MaxmindSettings added in v0.15.5

type MaxmindSettings struct {
	Database     string `cfg:"database"`
	S3ClientName string `cfg:"s3_client_name"`
}

type MemoryRecord

type MemoryRecord struct {
	CountryIso string `cfg:"country_iso"`
	CityName   string `cfg:"city_name"`
	TimeZone   string `cfg:"time_zone"`
}

type Provider

type Provider interface {
	City(ipAddress net.IP) (*geoip2.City, error)
	Refresh(ctx context.Context) error
	Close() error
}

func NewMaxmindProvider

func NewMaxmindProvider(ctx context.Context, config cfg.Config, logger log.Logger, name string) (Provider, error)

func NewMemoryProvider

func NewMemoryProvider(_ context.Context, _ cfg.Config, _ log.Logger, name string) (Provider, error)

type ProviderFactory

type ProviderFactory func(ctx context.Context, config cfg.Config, logger log.Logger, name string) (Provider, error)

type Reader

type Reader interface {
	City(ipString string) (*GeoCity, error)
}

type ReaderSettings

type ReaderSettings struct {
	Provider string          `cfg:"provider" default:"maxmind"`
	Refresh  RefreshSettings `cfg:"refresh"`
}

type RefreshModule added in v0.15.5

type RefreshModule struct {
	kernel.BackgroundModule
	kernel.ServiceStage
	kernel.HealthCheckedModule
	// contains filtered or unexported fields
}

func (*RefreshModule) IsHealthy added in v0.15.5

func (m *RefreshModule) IsHealthy(ctx context.Context) (bool, error)

func (*RefreshModule) Run added in v0.15.5

func (m *RefreshModule) Run(ctx context.Context) (err error)

type RefreshSettings added in v0.15.5

type RefreshSettings struct {
	Enabled  bool          `cfg:"enabled" default:"false"`
	Interval time.Duration `cfg:"interval" default:"24h"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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