query

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

The `query` package replaces the `filter` package and improves support for both read- and write-oriented configuration options.

Index

Constants

This section is empty.

Variables

View Source
var Infinite = Timeframe{}

A timeframe with no bounds, representing all time

View Source
var ZeroRange = Range{}

Functions

This section is empty.

Types

type Order

type Order int
const (
	Ascending Order = iota
	Descending
)

type Params

type Params map[string]interface{}

func (Params) Bool

func (p Params) Bool(n string) (bool, bool)

func (Params) Float64

func (p Params) Float64(n string) (float64, bool)

func (Params) Get

func (p Params) Get(n string) (interface{}, bool)

func (Params) Int

func (p Params) Int(n string) (int, bool)

func (*Params) Set

func (p *Params) Set(k string, v interface{})

func (Params) String

func (p Params) String(n string) (string, bool)

type Range

type Range struct {
	Offset int `json:"offset"`
	Length int `json:"length"`
}

func (Range) WithLength

func (r Range) WithLength(x int) Range

func (Range) WithOffset

func (r Range) WithOffset(x int) Range

type ReadConfig

type ReadConfig struct {
	Limit     Range
	Order     Order
	Timeframe Timeframe
	Params    Params
}

func NewReadConfig

func NewReadConfig(opts []ReadOption) ReadConfig

func (ReadConfig) Param

func (f ReadConfig) Param(n string) (interface{}, bool)

Param is deprecated: use `Params.Get` instead

func (ReadConfig) WithOptions

func (f ReadConfig) WithOptions(opts []ReadOption) ReadConfig

type ReadOption

type ReadOption func(ReadConfig) ReadConfig

func UseReadConfig

func UseReadConfig(c ReadConfig) ReadOption

func WithLimit

func WithLimit(r Range) ReadOption

func WithOrder

func WithOrder(o Order) ReadOption

func WithReadParams

func WithReadParams(p Params) ReadOption

func WithTimeframe

func WithTimeframe(t Timeframe) ReadOption

type Timeframe

type Timeframe struct {
	Since *time.Time `json:"since"`
	Until *time.Time `json:"until"`
}

A timeframe

func NewSince

func NewSince(f time.Time) Timeframe

Create a timeframe from the specified time to +inf

func NewTimeframe

func NewTimeframe(f, t time.Time) Timeframe

Create a timeframe

func NewUntil

func NewUntil(t time.Time) Timeframe

Create a timeframe from -inf to the specified time

func (Timeframe) CompareDuration

func (t Timeframe) CompareDuration(d time.Duration) int

CompareDuration compares the duration between t.Since and t.Until with the given duration

func (Timeframe) Contains

func (t Timeframe) Contains(a time.Time) bool

Determine if the timeframe contains the specified time. Timeframes are inclusive on the lower bound and exclusive on the upper bound.

func (Timeframe) Duration

func (t Timeframe) Duration() time.Duration

What is the duration of the timeframe. If a timeframe is not bounded on both ends, the duration is infinite, which is expressed as a negative value. If Until is before Since, the value will also be negative, this is a logically invalid state that is interpreted as the timeframe being unbounded.

func (Timeframe) Format

func (t Timeframe) Format(layout string) string

func (Timeframe) IsFinite

func (t Timeframe) IsFinite() bool

Is a timeframe finite (is bounded)

func (Timeframe) String

func (t Timeframe) String() string

type WriteConfig

type WriteConfig struct {
	Cascade bool
	Params  Params
}

func NewWriteConfig

func NewWriteConfig(opts []WriteOption) WriteConfig

func (WriteConfig) WithOptions

func (c WriteConfig) WithOptions(opts []WriteOption) WriteConfig

type WriteOption

type WriteOption func(WriteConfig) WriteConfig

func UseWriteConfig

func UseWriteConfig(c WriteConfig) WriteOption

func WithCascade

func WithCascade() WriteOption

func WithWriteParams

func WithWriteParams(p Params) WriteOption

Jump to

Keyboard shortcuts

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