timed

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: BSD-3-Clause Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Hourly period = iota
	Daily
	Monthly
	Yearly
)

Periods for database partitioning.

Variables

View Source
var (
	// ErrUnknownDB is error that is returned when database file can not be found.
	ErrUnknownDB = errors.New("unknown database")
	// ErrUnknownPeriod is returned if provided database period is not valid.
	ErrUnknownPeriod = errors.New("unknown period")
)

Functions

This section is empty.

Types

type Connection

type Connection struct {
	*boltdbpool.Connection
	// contains filtered or unexported fields
}

Connection represents a boltdbpool.Connection for a particular time partition.

func (*Connection) Next

func (c *Connection) Next() (*Connection, error)

Next returns a connection that holds newer data relative to the data partition of the current connection.

func (*Connection) Prev

func (c *Connection) Prev() (*Connection, error)

Prev returns a connection that holds older data relative to the data partition of the current connection.

type Pool

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

Pool holds database connections and database information.

func New

func New(dir string, p period, options *boltdbpool.Options) (*Pool, error)

New returns a new instance of Pool with database files in dir, partitioned by period and each database connection created with options.

func (*Pool) Close

func (p *Pool) Close()

Close closes underlying boltdbpool.Pool.

func (*Pool) GetConnection

func (p *Pool) GetConnection(t time.Time) (conn *Connection, err error)

GetConnection returns a Connection if the database for the provided time exists.

func (*Pool) NewConnection

func (p *Pool) NewConnection(t time.Time) (conn *Connection, err error)

NewConnection returns a Connection either from the pool, or creates a new one for a database that should hold or holds data for a provided time.

func (*Pool) NextConnection

func (p *Pool) NextConnection(t time.Time) (conn *Connection, err error)

NextConnection returns a Connection to a database that holds data newer related to the provided time.

func (*Pool) PrevConnection

func (p *Pool) PrevConnection(t time.Time) (conn *Connection, err error)

PrevConnection returns a Connection to a database that holds data older related to the provided time.

Jump to

Keyboard shortcuts

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