evredis

package
v0.1.0-beta9 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package evredis provides an evdb backend using Redis

Index

Constants

View Source
const (
	DailyDateFormat  string = "2006-01-02"
	HourlyDateFormat string = "2006-01-02-15"
)

Date formats

View Source
const (
	Hourly  = time.Hour
	Daily   = 24 * time.Hour
	Weekly  = 7 * Daily
	Monthly = 30 * Daily
	Yearly  = 365 * Daily
)

Common durations

Variables

View Source
var (
	// NoResolution     = Resolution{"totals", 0, 0, NoResolutionCodec}
	ResolutionHourly = Resolution{"hourly", 0, Hourly, tcodec.LayoutCodec(HourlyDateFormat)}
	ResolutionDaily  = Resolution{"daily", 0, Daily, tcodec.LayoutCodec(DailyDateFormat)}
	ResolutionWeekly = Resolution{"weekly", 0, Weekly, tcodec.ISOWeekCodec}
)

Common resolutions

Functions

This section is empty.

Types

type DB

type DB struct {
	evdb.Scanner
	// contains filtered or unexported fields
}

DB is an evdb backend using Redis

func Open

func Open(options Options, events ...string) (*DB, error)

Open opens a new DB

func (*DB) Close

func (db *DB) Close() error

Close closes a DB

func (*DB) Register

func (db *DB) Register(event string) (evdb.Storer, error)

Register registers a new event

func (*DB) ScanQuery

func (db *DB) ScanQuery(ctx context.Context, q *evdb.ScanQuery) (evdb.Results, error)

ScanQuery implements evdb.ScanQuerier interface

func (*DB) Storer

func (db *DB) Storer(event string) evdb.Storer

Storer provides a Storer for an event

type Options

type Options struct {
	Redis       string
	ScanSize    int64
	KeyPrefix   string
	Resolutions []Resolution
}

Options are options for a DB

func ParseURL

func ParseURL(configURL string) (o Options, err error)

ParseURL parses options from a URL

type Resolution

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

Resolution describes time dimensions

func NewResolution

func NewResolution(name string, step, ttl time.Duration) Resolution

func (Resolution) AddSteps

func (r Resolution) AddSteps(t time.Time, n int) time.Time

func (Resolution) IsZero

func (r Resolution) IsZero() bool

func (Resolution) MarshalTime

func (r Resolution) MarshalTime(t time.Time) string

func (Resolution) Name

func (r Resolution) Name() string

func (Resolution) Step

func (r Resolution) Step() time.Duration

func (Resolution) TTL

func (r Resolution) TTL() time.Duration

func (Resolution) Truncate

func (r Resolution) Truncate(t time.Time) time.Time

func (Resolution) UnmarshalTime

func (r Resolution) UnmarshalTime(s string) (t time.Time, err error)

func (Resolution) WithCodec

func (r Resolution) WithCodec(codec tcodec.TimeCodec) Resolution

func (Resolution) WithLayout

func (r Resolution) WithLayout(layout string) Resolution

func (Resolution) WithName

func (r Resolution) WithName(name string) Resolution

func (Resolution) WithStep

func (r Resolution) WithStep(step time.Duration) Resolution

func (Resolution) WithTTL

func (r Resolution) WithTTL(ttl time.Duration) Resolution

Jump to

Keyboard shortcuts

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