backend

package
v0.0.0-...-9f1f843 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultIdentifier = "default"
View Source
const MemoryType = TypeBackend("memory")
View Source
const MetadataLocalCacheDuration = 1000 * time.Millisecond
View Source
const RedisCluster = "cluster"
View Source
const RedisDefaultConnectionNamespace = Namespace(0)
View Source
const RedisMemory = "memory" // miniredis client
View Source
const RedisOptsKey = "redis"
View Source
const RedisServer = "server"
View Source
const RedisType = TypeBackend("redis")

Variables

View Source
var SimpleStrategyType = StrategyType("simple")

Functions

func FloatToString

func FloatToString(val float64) string

func IsEmptyRequestId

func IsEmptyRequestId(r RequestId) bool

Types

type AbstractBackend

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

func (*AbstractBackend) ReverseApi

func (a *AbstractBackend) ReverseApi() IReverseApi

func (*AbstractBackend) SetReverseApi

func (a *AbstractBackend) SetReverseApi(reverseApi IReverseApi)

type AbstractBackendWithMetadata

type AbstractBackendWithMetadata interface {
	IAbstractBackend
	IMetadata
}

backend that supports both metadata and storage

type AbstractStrategy

type AbstractStrategy interface {
	GetBackend() IAbstractBackend
	SetBackends([]IAbstractBackend)
}

func NewSimpleStrategy

func NewSimpleStrategy() AbstractStrategy

func StrategyInstanceFactory

func StrategyInstanceFactory(typeStr string, opts map[string]interface{}) AbstractStrategy

type Context

type Context struct {
	// details to determine context (e.g. series / metadata of series for persistence level)
	Series    uint64
	Namespace int
	RequestId RequestId
}

type ContextBackend

type ContextBackend struct {
	Context
}

type ContextRead

type ContextRead struct {
	Context
	From uint64
	To   uint64
}

type ContextWrite

type ContextWrite struct {
	Context
}

type CreateSeries

type CreateSeries struct {
	Series map[types.SeriesCreateIdentifier]types.SeriesCreateMetadata
}

type CreateSeriesResult

type CreateSeriesResult struct {
	Results map[types.SeriesCreateIdentifier]types.SeriesMetadataResponse
	Error   error
}

type DeleteSeries

type DeleteSeries struct {
	Series []types.SeriesIdentifier
}

type DeleteSeriesResult

type DeleteSeriesResult struct {
	Error error
}

type IAbstractBackend

type IAbstractBackend interface {
	Type() TypeBackend
	Write(context ContextWrite, timestamps []uint64, values []float64) error
	FlushPendingWrites(requestId RequestId) error
	Read(context ContextRead) ReadResult
	Init() error // should be called before first usage
	SetReverseApi(IReverseApi)
}

func InstanceFactory

func InstanceFactory(typeStr string, opts map[string]interface{}) IAbstractBackend

type IMetadata

type IMetadata interface {
	CreateOrUpdateSeries(*CreateSeries) *CreateSeriesResult // create/update new series (batch)
	SearchSeries(*SearchSeries) *SearchSeriesResult         // search one or multiple series by tags
	DeleteSeries(*DeleteSeries) *DeleteSeriesResult         // remove series (batch)
	Clear() error                                           // clear all data, mainly used for testing
}

type IReverseApi

type IReverseApi interface {
	DeleteSeries(delete *DeleteSeries) *DeleteSeriesResult
}

the backend implementation can callback into a limited set of APIs to achieve things for example if TTL expiry is implemented on-read it will have to instruct removal of that series

type MemoryBackend

type MemoryBackend struct {
	AbstractBackend
	// contains filtered or unexported fields
}

func NewMemoryBackend

func NewMemoryBackend() *MemoryBackend

func (*MemoryBackend) Clear

func (instance *MemoryBackend) Clear() error

func (*MemoryBackend) CreateOrUpdateSeries

func (instance *MemoryBackend) CreateOrUpdateSeries(create *CreateSeries) (result *CreateSeriesResult)

func (*MemoryBackend) DeleteSeries

func (instance *MemoryBackend) DeleteSeries(ops *DeleteSeries) (result *DeleteSeriesResult)

func (*MemoryBackend) FlushPendingWrites

func (instance *MemoryBackend) FlushPendingWrites(RequestId) error

func (*MemoryBackend) GetSeriesMeta

func (instance *MemoryBackend) GetSeriesMeta(s Series) *SeriesMetadata

func (*MemoryBackend) Init

func (instance *MemoryBackend) Init() error

func (*MemoryBackend) Read

func (instance *MemoryBackend) Read(context ContextRead) (res ReadResult)

func (*MemoryBackend) SearchSeries

func (instance *MemoryBackend) SearchSeries(search *SearchSeries) (result *SearchSeriesResult)

func (*MemoryBackend) Type

func (instance *MemoryBackend) Type() TypeBackend

func (*MemoryBackend) Write

func (instance *MemoryBackend) Write(context ContextWrite, timestamps []uint64, values []float64) error

type Metadata

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

func NewMetadata

func NewMetadata(backend AbstractBackendWithMetadata) *Metadata

func (*Metadata) Clear

func (meta *Metadata) Clear() error

func (*Metadata) CreateOrUpdateSeries

func (meta *Metadata) CreateOrUpdateSeries(create *CreateSeries) *CreateSeriesResult

func (*Metadata) DeleteSeries

func (meta *Metadata) DeleteSeries(delete *DeleteSeries) *DeleteSeriesResult

func (*Metadata) SearchSeries

func (meta *Metadata) SearchSeries(search *SearchSeries) *SearchSeriesResult

type Namespace

type Namespace int

func (Namespace) Int

func (n Namespace) Int() int

type ReadResult

type ReadResult struct {
	Error   error
	Results map[uint64]float64
}

type RedisBackend

type RedisBackend struct {
	AbstractBackend
	// contains filtered or unexported fields
}

func NewRedisBackend

func NewRedisBackend(opts *RedisOpts) *RedisBackend

func (*RedisBackend) Clear

func (instance *RedisBackend) Clear() error

func (*RedisBackend) CreateOrUpdateSeries

func (instance *RedisBackend) CreateOrUpdateSeries(create *CreateSeries) (result *CreateSeriesResult)

func (*RedisBackend) DeleteSeries

func (instance *RedisBackend) DeleteSeries(ops *DeleteSeries) (result *DeleteSeriesResult)

func (*RedisBackend) FlushPendingWrites

func (instance *RedisBackend) FlushPendingWrites(requestId RequestId) error

func (*RedisBackend) GetConnection

func (instance *RedisBackend) GetConnection(namespace Namespace) redis.UniversalClient

func (*RedisBackend) Init

func (instance *RedisBackend) Init() error

func (*RedisBackend) Read

func (instance *RedisBackend) Read(context ContextRead) (res ReadResult)

func (*RedisBackend) SearchSeries

func (instance *RedisBackend) SearchSeries(search *SearchSeries) (result *SearchSeriesResult)

func (*RedisBackend) Type

func (instance *RedisBackend) Type() TypeBackend

func (*RedisBackend) Write

func (instance *RedisBackend) Write(context ContextWrite, timestamps []uint64, values []float64) error

type RedisConnectionDetails

type RedisConnectionDetails struct {
	Type     RedisServerType //sentinel cluster server
	Addr     string
	Port     int
	Password string
	Database int
}

type RedisOpts

type RedisOpts struct {
	// connection per namespace supported, use RedisDefaultConnectionNamespace for default
	ConnectionDetails map[Namespace]RedisConnectionDetails
}

func ExtractRedisOpts

func ExtractRedisOpts(opts map[string]interface{}) *RedisOpts

type RedisServerType

type RedisServerType string

type RequestId

type RequestId string

func NewRequestId

func NewRequestId() RequestId

type SearchSeries

type SearchSeries struct {
	SearchSeriesElement
}

type SearchSeriesComparator

type SearchSeriesComparator string
const SearchSeriesComparatorEquals SearchSeriesComparator = "EQUALS"
const SearchSeriesComparatorNot SearchSeriesComparator = "NOT"

type SearchSeriesElement

type SearchSeriesElement struct {
	Namespace  int
	Name       string
	Tag        string
	Comparator SearchSeriesComparator
	And        []SearchSeriesElement
	Or         []SearchSeriesElement
}

type SearchSeriesResult

type SearchSeriesResult struct {
	Series []types.SeriesIdentifier
	Error  error
}

type Selector

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

func NewSelector

func NewSelector() *Selector

func (*Selector) AddStrategy

func (selector *Selector) AddStrategy(strategy AbstractStrategy) error

func (*Selector) SelectStrategy

func (selector *Selector) SelectStrategy(context ContextBackend) (AbstractStrategy, error)

type Series

type Series uint64

type SeriesMetadata

type SeriesMetadata struct {
	Id        Series
	Namespace Namespace
	Name      string
	Tags      []string `json:",omitempty"`
	TtlExpire uint64   `json:",omitempty"` //  0 OR time in the future in seconds
}

type SimpleStrategy

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

func (*SimpleStrategy) GetBackend

func (strategy *SimpleStrategy) GetBackend() IAbstractBackend

func (*SimpleStrategy) SetBackends

func (strategy *SimpleStrategy) SetBackends(backend []IAbstractBackend)

type StrategyType

type StrategyType string

func (StrategyType) String

func (t StrategyType) String() string

type Timestamp

type Timestamp float64

type TypeBackend

type TypeBackend string

func (TypeBackend) String

func (t TypeBackend) String() string

Jump to

Keyboard shortcuts

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