mdbd

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: Apache-2.0 Imports: 21 Imported by: 6

Documentation

Overview

Package mdbd implements a simple MDB watcher.

Package mdbd may be used to read MDB data from a file or remote server and watch for updates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartMdbDaemon

func StartMdbDaemon(mdbFileName string, logger log.Logger) <-chan *mdb.Mdb

StartMdbDaemon is a convenience wrapper for StartMdbDaemon2. The -mdbServerHostname and -mdbServerPortNum command-line flags are used for the corresponding Params fields.

func StartMdbDaemon2 added in v0.10.0

func StartMdbDaemon2(config Config, params Params) <-chan *mdb.Mdb

StartMdbDaemon2 starts an in-process "daemon" goroutine which watches for MDB updates. At startup it will read the file named by config.MdbFileName for MDB data. The default format is JSON, but if the filename extension is ".gob" then GOB format is read. If the file is present and contains MDB data, the MDB data are sent over the returned channel, otherwise no MDB data are sent initially.

By default the file is monitored for updates and if the file is replaced by a different inode, MDB data are read from the new inode. If the MDB data are different than previously read, they are sent over the channel. This mode of operation is designed for consuming MDB data via the file-system from a local mdbd daemon.

Alternatively, if a remote MDB server is specified with the config.MdbServerHostname and config.MdbServerPortNum fields then the remote MDB server is queried for MDB data. As MDB updates are received they are saved in the file and sent over the channel. In this mode of operation the file is read only once at startup, and is replaced when MDB updates are received. The file acts as a local cache of the MDB data received from the server, in case the MDB server is not available at a subsequent restart of the application.

The params.Logger will be used to log problems.

Types

type Config added in v0.10.0

type Config struct {
	MdbFileName       string
	MdbServerHostname string
	MdbServerPortNum  uint
}

type Params added in v0.10.0

type Params struct {
	Logger log.DebugLogger
}

Jump to

Keyboard shortcuts

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