keysbuilder

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package keysbuilder holds a datastructure to get and update requested keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder builds the keys. It is not save for concourent use. There is one Builder instance per client. It is not allowed to call builder.Update() more then once or at the same time as builder.Keys(). It is ok to call builder.Keys() at the same time more then once.

Has to be created with keysbuilder.FromJSON() or keysbuilder.ManyFromJSON().

func FromBuilders

func FromBuilders(builders ...*Builder) *Builder

FromBuilders creates a new keysbuilder from a list of other builders.

func FromJSON

func FromJSON(r io.Reader) (*Builder, error)

FromJSON creates a Keysbuilder from json.

func FromKeys

func FromKeys(keys []string) (*Builder, error)

FromKeys creates a keysbuilder from a list of keys.

func ManyFromJSON

func ManyFromJSON(r io.Reader) (*Builder, error)

ManyFromJSON creates a list of Keysbuilder objects from a json list.

func (*Builder) Keys

func (b *Builder) Keys() []string

Keys returns the keys.

Make sure to call Update() or Keys() will return an empty list.

func (*Builder) Update

func (b *Builder) Update(ctx context.Context, getter datastore.Getter) (err error)

Update triggers a key update. It generates the list of keys, that can be requested with the Keys() method. It travels the KeysRequests object like a tree.

It is not allowed to call builder.Keys() after Update returned an error.

type InvalidError

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

InvalidError is an error that happens on an invalid request.

func (InvalidError) Error

func (e InvalidError) Error() string

func (InvalidError) Fields

func (e InvalidError) Fields() []string

Fields returns a list of field names from the parent to this error.

func (InvalidError) Type

func (e InvalidError) Type() string

Type returns the name of the error.

type JSONError

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

JSONError is returned when invalid json is parsed or the json can not be decoded as a keysbuilder.

func (JSONError) Error

func (e JSONError) Error() string

func (JSONError) Type

func (e JSONError) Type() string

Type returns the name of the error.

func (JSONError) Unwrap

func (e JSONError) Unwrap() error

Unwrap returns the thrown error.

type Simple

type Simple struct {
	K []string
}

Simple implements the autoupdate.Keysbuilder interface. It returns the keys it was initialized with.

func (*Simple) Keys

func (s *Simple) Keys() []string

Keys returns the keys the keysbuilder.Simple was initialized.

func (*Simple) Update

Update does nothing. The keys of a simple keysbuilder can not change.

type ValueError

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

ValueError in returned by keysbuilder.Update(), when the value of a key has not the expected format.

func (ValueError) Error

func (e ValueError) Error() string

func (ValueError) Type

func (e ValueError) Type() string

Type returns the name of the error.

func (ValueError) Unwrap

func (e ValueError) Unwrap() error

Unwrap returns the thrown error.

Jump to

Keyboard shortcuts

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