badgerdb

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package badgerdb implements the storage interface with BadgerDB

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdditionalOptions

type AdditionalOptions struct {
	TTL time.Duration
}

AdditionalOptions are additional options for setting up BadgerDB

type Client

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

Client is a client for the BadgerDB

func GetClient

func GetClient(opts badger.Options, additionalOptions AdditionalOptions) (*Client, error)

GetClient gets a client for the BadgerDB

func (Client) GetExperimentResult added in v0.16.0

func (cl Client) GetExperimentResult(namespace, experiment string) (*base.ExperimentResult, error)

GetExperimentResult sets the experiment result for a particular namespace and experiment name the data is []byte in order to make this function reusable for different tasks

func (Client) GetMetrics

func (cl Client) GetMetrics(applicationName string, version int, signature string) (*storage.VersionMetrics, error)

GetMetrics returns a nested map of the metrics data for a particular application, version, and signature Example:

{
	"my-metric": {
		"MetricsOverTransactions": [1, 1, 3, 4, 5]
		"MetricsOverUsers": [2, 7, 5]
	}
}

NOTE: for users that have not produced any metrics (for example, via lookup()), GetMetrics() will add 0s for the extra users in metricsOverUsers

Example, given 5 total users:

{
	"my-metric": {
		"MetricsOverTransactions": [1, 1, 3, 4, 5]
		"MetricsOverUsers": [2, 7, 5, 0, 0]
	}
}

func (Client) SetExperimentResult added in v0.16.0

func (cl Client) SetExperimentResult(namespace, experiment string, data *base.ExperimentResult) error

SetExperimentResult sets the experiment result for a particular namespace and experiment name the data is []byte in order to make this function reusable for different tasks

func (Client) SetMetric

func (cl Client) SetMetric(applicationName string, version int, signature, metric, user, transaction string, metricValue float64) error

SetMetric sets a metric based on the app name, version, signature, metric type, user name, transaction ID, and metric value with BadgerDB Example key: kt-metric::my-app::0::my-signature::my-metric::my-user::my-transaction-id -> my-metric-value

func (Client) SetUser

func (cl Client) SetUser(applicationName string, version int, signature, user string) error

SetUser sets a user based on the app name, version, signature, and user name with BadgerDB Example key/value: kt-users::my-app::0::my-signature::my-user -> true

type ClientConfig added in v0.18.6

type ClientConfig struct {
	Storage          *string `json:"storage,omitempty"`
	StorageClassName *string `json:"storageClassName,omitempty"`
	Dir              *string `json:"dir,omitempty"`
}

ClientConfig is configurable properties of a new BadgerDB client

Jump to

Keyboard shortcuts

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