counter

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Type primitive.Type = "Counter"

Type is the counter type

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GetCounter gets the Counter instance of the given name
	GetCounter(ctx context.Context, name string) (Counter, error)
}

Client provides an API for creating Counters

type Counter

type Counter interface {
	primitive.Primitive

	// Get gets the current value of the counter
	Get(ctx context.Context) (int64, error)

	// Set sets the value of the counter
	Set(ctx context.Context, value int64) error

	// Increment increments the counter by the given delta
	Increment(ctx context.Context, delta int64) (int64, error)

	// Decrement decrements the counter by the given delta
	Decrement(ctx context.Context, delta int64) (int64, error)
}

Counter provides a distributed atomic counter

func New

func New(ctx context.Context, name primitive.Name, partitions []*primitive.Session) (Counter, error)

New creates a new counter for the given partitions

Jump to

Keyboard shortcuts

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