Documentation
¶
Overview ¶
Package database provides MaxMind database management functionality.
Index ¶
- type Info
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) GetDatabase(name string) (*Info, bool)
- func (m *Manager) GetReader(name string) (*maxminddb.Reader, bool)
- func (m *Manager) ListDatabases() []*Info
- func (m *Manager) LoadDatabase(path string) error
- func (m *Manager) LoadDirectory(dir string) error
- func (m *Manager) RemoveDatabase(name string)
- func (m *Manager) RemoveDatabaseByPath(path string)
- func (m *Manager) StartWatching()
- func (m *Manager) WatchDirectory(dir string) error
- type UpdateResult
- type Updater
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { LastUpdated time.Time `json:"last_updated"` Name string `json:"name"` Type string `json:"type"` Description string `json:"description"` Path string `json:"-"` Size int64 `json:"size"` }
Info holds metadata about a database.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles MMDB database lifecycle.
func (*Manager) Close ¶
Close closes the file watcher and clears the database maps. Readers are not explicitly closed to avoid races with active iterators; they will be garbage collected when no longer referenced.
func (*Manager) GetDatabase ¶
GetDatabase returns database info for the specified database by display name.
func (*Manager) ListDatabases ¶
ListDatabases returns all available databases.
func (*Manager) LoadDatabase ¶
LoadDatabase loads a single MMDB file.
func (*Manager) LoadDirectory ¶
LoadDirectory scans a directory for MMDB files and loads them.
func (*Manager) RemoveDatabase ¶
RemoveDatabase removes a database by display name from the manager.
func (*Manager) RemoveDatabaseByPath ¶
RemoveDatabaseByPath removes a database by absolute path from the manager.
func (*Manager) StartWatching ¶
func (m *Manager) StartWatching()
StartWatching starts the file watcher goroutine.
func (*Manager) WatchDirectory ¶
WatchDirectory adds a directory to be watched for file changes.
type UpdateResult ¶
type UpdateResult struct { LastUpdate time.Time `json:"last_update"` Database string `json:"database"` Error string `json:"error,omitempty"` Size int64 `json:"size,omitempty"` Updated bool `json:"updated"` }
UpdateResult represents the result of an update operation.
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater handles downloading and updating MaxMind databases.
func NewUpdater ¶
NewUpdater creates a new database updater.
func (*Updater) StartScheduledUpdates ¶
StartScheduledUpdates starts a goroutine that periodically updates databases.
func (*Updater) UpdateAll ¶
func (u *Updater) UpdateAll(ctx context.Context) ([]UpdateResult, error)
UpdateAll updates all configured databases.
func (*Updater) UpdateDatabase ¶
UpdateDatabase updates a specific database.