state

package
v0.0.0-...-1351b60 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 5 Imported by: 8

Documentation

Index

Constants

View Source
const (
	DefaultPollInterval = 3 * time.Second
	DefaultPollTimeout  = 2 * time.Minute
)

Variables

This section is empty.

Functions

func ContextWith

func ContextWith(ctx context.Context, s Store) context.Context

ContextWith decorates the given context with the provided Store, and returns the resulting context.

func ContextWithPollTimings

func ContextWithPollTimings(ctx context.Context, interval, timeout time.Duration) context.Context

ContextWithPollTimings returns a context with poll timings set

func GetOrFail

func GetOrFail(ctx context.Context, t fail, key string, value interface{})

Get gets the key from the Store into the provided value

func GetStringOrFail

func GetStringOrFail(ctx context.Context, t fail, key string) string

Get the string value from the kvstore from key.

func PollTimingsFromContext

func PollTimingsFromContext(ctx context.Context) (time.Duration, time.Duration)

PollTimingsFromContext will get the previously set poll timing from context, or return the defaults if not found. - values from context. - defaults.

func SetOrFail

func SetOrFail(ctx context.Context, t fail, key string, value interface{})

Set sets the key into the Store from the provided value

Types

type KVStore

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

func (*KVStore) Get

func (cs *KVStore) Get(_ context.Context, key string, value interface{}) error

Get retrieves and unmarshals the value from the map.

func (*KVStore) MarshalJSON

func (cs *KVStore) MarshalJSON() ([]byte, error)

func (*KVStore) Set

func (cs *KVStore) Set(_ context.Context, key string, value interface{}) error

Set marshals and sets the value given under specified key.

type Store

type Store interface {
	// Get gets the key from the Store into the provided value
	Get(ctx context.Context, key string, value interface{}) error
	// Set sets the key into the Store from the provided value
	Set(ctx context.Context, key string, value interface{}) error
}

This is a subset of knative.dev/pkg/kvstore.Interface

func FromContext

func FromContext(ctx context.Context) Store

FromContext returns the Store from Context, if not found FromContext will panic. TODO: revisit if we really want to panic here... likely not.

Jump to

Keyboard shortcuts

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