aspects

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aspect

type Aspect struct {
	Name string
	// contains filtered or unexported fields
}

Aspect is a group of access patterns under a directory.

func (*Aspect) Get

func (a *Aspect) Get(name string, value interface{}) error

Get returns the aspect value identified by the name. If either the named aspect or the corresponding value can't be found, a NotFoundError is returned.

func (*Aspect) Set

func (a *Aspect) Set(name string, value interface{}) error

Set sets the named aspect to a specified value.

type DataBag

type DataBag interface {
	Get(path string, value interface{}) error
	Set(path string, value interface{}) error
	Data() ([]byte, error)
}

DataBag controls access to the aspect data storage.

type Directory

type Directory struct {
	Name string
	// contains filtered or unexported fields
}

Directory holds a series of related aspects.

func NewAspectDirectory

func NewAspectDirectory(name string, aspects map[string]interface{}, dataBag DataBag, schema Schema) (*Directory, error)

NewAspectDirectory returns a new aspect directory for the following aspects and access patterns.

func (*Directory) Aspect

func (d *Directory) Aspect(aspect string) *Aspect

Aspect returns an aspect from the aspect directory.

type JSONDataBag

type JSONDataBag map[string]json.RawMessage

JSONDataBag is a simple DataBag implementation that keeps JSON in-memory.

func NewJSONDataBag

func NewJSONDataBag() JSONDataBag

NewJSONDataBag returns a DataBag implementation that stores data in JSON. The top-level of the JSON structure is always a map.

func (JSONDataBag) Data

func (s JSONDataBag) Data() ([]byte, error)

Data returns all of the bag's data encoded in JSON.

func (JSONDataBag) Get

func (s JSONDataBag) Get(path string, value interface{}) error

Get takes a path and a pointer to a variable into which the value referenced by the path is written. The path can be dotted. For each dot a JSON object is expected to exist (e.g., "a.b" is mapped to {"a": {"b": <value>}}).

func (JSONDataBag) Set

func (s JSONDataBag) Set(path string, value interface{}) error

Set takes a path to which the value will be written. The path can be dotted, in which case, a nested JSON object is created for each sub-key found after a dot.

type JSONSchema

type JSONSchema struct{}

JSONSchema is the Schema implementation corresponding to JSONDataBag and it's able to validate its data.

func NewJSONSchema

func NewJSONSchema() *JSONSchema

NewJSONSchema returns a Schema able to validate a JSONDataBag's data.

func (*JSONSchema) Validate

func (s *JSONSchema) Validate(jsonData []byte) error

Validate validates that the specified data can be encoded into JSON.

type NotFoundError

type NotFoundError struct {
	Message string
}

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

func (*NotFoundError) Is

func (e *NotFoundError) Is(err error) bool

type Schema

type Schema interface {
	Validate(data []byte) error
}

Schema takes in data from the DataBag and validates that it's valid and could be committed.

Jump to

Keyboard shortcuts

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