runtime

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2018 License: Apache-2.0 Imports: 3 Imported by: 72

Documentation

Index

Constants

View Source
const (
	// FirstGen is a number of the first generation for an object
	FirstGen Generation = 1

	// LastGen is a number of the initial generation for an object
	LastGen Generation = 0

	// SystemNS is a name of system namespace
	SystemNS = "system"

	// EmptyName is the default empty name for runtime objects
	EmptyName = ""
)
View Source
const KeySeparator = "/"

KeySeparator is used to separate key parts (namespace, kind, name)

View Source
const MaxGeneration = Generation(math.MaxUint64)

MaxGeneration is a constant which defines max value for a generation

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Encoder
	Decoder
}

Codec interface represents combination of Encoder and Decoder interfaces for both sides encoding/decoding of runtime objects to/from bytes

type Constructor

type Constructor func() Object

Constructor is a function to get instance of the specific object

type Decoder

type Decoder interface {
	DecodeOne(data []byte) (Object, error)
	DecodeOneOrMany(data []byte) ([]Object, error)
}

Decoder interface represents decoding of the runtime objects from bytes

type Deletable added in v0.1.10

type Deletable interface {
	Versioned
	IsDeleted() bool
	SetDeleted(bool)
}

Deletable extends Versioned with deleted marker to represent versioned objects that could be marked as deleted, but then created again even with the same content. Best example of such objects is policy objects (and the only for now).

type Displayable added in v0.1.2

type Displayable interface {
	GetDefaultColumns() []string
	AsColumns() map[string]string
}

Displayable represents object that could be represented as columns and have some default set of columns to be shown

type Encoder

type Encoder interface {
	EncodeOne(obj Object) ([]byte, error)
	EncodeMany(objs []Object) ([]byte, error)
}

Encoder interface represents encoding of the runtime objects into bytes

type Generation

type Generation uint64

Generation represents object's "version" and starts from 0

func ParseGeneration

func ParseGeneration(gen string) Generation

ParseGeneration returns Generation type representation of specified generation string

func (Generation) Next

func (gen Generation) Next() Generation

Next returns the next generation of the base object (current + 1)

func (Generation) String

func (gen Generation) String() string

String returns generation as string to implement Stringer interface

type GenerationMetadata

type GenerationMetadata struct {
	Generation Generation
}

GenerationMetadata is the default struct for metadata with only generation in it

type Info

type Info struct {
	Kind        Kind
	Storable    bool
	Versioned   bool
	Deletable   bool
	Constructor Constructor
}

Info represents list of additional characteristics of the runtime object

func AppendAll

func AppendAll(all ...[]*Info) []*Info

AppendAll concatenates all provided info slices into a single info slice

func (*Info) GetTypeKind

func (info *Info) GetTypeKind() TypeKind

GetTypeKind returns TypeKind instance for the object described by info

func (*Info) New

func (info *Info) New() Object

New creates a new instance of the specific object defined in Info

type Key

type Key = string

Key represents storable object key - namespace + kind + name separated by KeySeparator

func KeyForStorable

func KeyForStorable(obj Storable) Key

KeyForStorable returns Key for storable object

func KeyFromParts

func KeyFromParts(namespace string, kind Kind, name string) Key

KeyFromParts returns Key build using provided parts (namespace, kind, name)

type Kind

type Kind = string

Kind represents runtime object Kind

type Object

type Object interface {
	GetKind() Kind
}

Object represents minimal object that could be operated in runtime with only Kind being mandatory characteristic

type Registry

type Registry struct {
	Kinds map[string]*Info
}

Registry contains a map of objects info structures by their kind

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new Registry

func (*Registry) Append

func (reg *Registry) Append(infos ...*Info) *Registry

Append adds specified list of object Info into the registry

func (*Registry) Get

func (reg *Registry) Get(kind Kind) *Info

Get looks up object informational structure given its kind

type Storable

type Storable interface {
	Object
	GetName() string
	GetNamespace() string
}

Storable represents runtime object that could be stored in database and having two additional mandatory characteristics: Name and Namespace that together with Kind forms Key (namespace + kind + name) that represents coordinates of the object in database

type TypeKind

type TypeKind struct {
	Kind Kind
}

TypeKind represents type definition of the runtime object, should be embedded into all runtime objects with `yaml:",inline"` for proper yaml codec encoding and decoding

func (*TypeKind) GetKind

func (tk *TypeKind) GetKind() Kind

GetKind returns Kind

type Versioned

type Versioned interface {
	Storable
	GetGeneration() Generation
	SetGeneration(gen Generation)
}

Versioned extends Storable with mandatory Generation characteristic to represent versioned objects that are having multiple generations stored in database

Directories

Path Synopsis
codec
core
Package core allows to persist Aptomi engine objects into the object store.
Package core allows to persist Aptomi engine objects into the object store.

Jump to

Keyboard shortcuts

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