services

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DatastoreKV collection KV
	DatastoreKV string = "KV"
	// DefaultExpiration is the minimum time to keep an entry in the store
	DefaultExpiration int64 = 86400 * 14 // 14 days
)
View Source
const (
	// DatastoreMetrics collection of metrics
	DatastoreMetrics string = "METRICS"
	// CountType is a int counter
	CountType = "COUNTER"
)
View Source
const (
	// DatastoreJobs collection of job / cron metadata
	DatastoreJobs string = "JOBS"
)

Variables

This section is empty.

Functions

func Count

func Count(ctx context.Context, name, label string, value int) error

Count records a numeric counter value

func CreateSimpleTask

func CreateSimpleTask(ctx context.Context, handler, payload string) (*taskspb.Task, error)

CreateSimpleTask is used to schedule a background task using the default queue. The payload is a simple string, i.e. no marshalling happens.

func CreateTask

func CreateTask(ctx context.Context, handler string, payload interface{}) (*taskspb.Task, error)

CreateTask is used to schedule a background task using the default queue. The payload can be any struct and will be marshalled into a json string.

func GetJobTimestamp

func GetJobTimestamp(ctx context.Context, name string) int64

GetJobTimestamp returns the timestamp when a job was last executed

func GetKV

func GetKV(ctx context.Context, k string) (string, error)

GetKV retrieves a value from the store or raises an exception if it does not exist

func InvalidateKV

func InvalidateKV(ctx context.Context, k string)

InvalidateKV removes an entry from the cache

func SetKV

func SetKV(ctx context.Context, k, v string, duration int64) error

SetKV adds an entry to the store. Existing values get updated

func UpdateJob

func UpdateJob(ctx context.Context, name string, ts int64) error

UpdateJob updates the timestamp and count of the job metadata

Types

type Counter

type Counter struct {
	Metric
	Value int64
}

Counter is a metric to collect integer values

type Job

type Job struct {
	Name    string
	Count   int
	LastRun int64
}

Job is the datastructure to store when a job was last run

type KV

type KV struct {
	Key     string
	Value   string
	Expires int64
}

KV is the datastructure to store stuff

type Metric

type Metric struct {
	Name    string // unique name of the metric
	Label   string // additional context, e.g. an id, name/value pairs, comma separated labels etc
	Type    string // the type, e.g. count,
	Created int64
}

Metric is a generic data structure to store metrics

Jump to

Keyboard shortcuts

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