registry

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: MIT Imports: 12 Imported by: 19

Documentation

Overview

Code generated by mockery v2.13.0-beta.1. DO NOT EDIT.

Index

Constants

View Source
const (
	// DirectoryGlobal contains the registry key to the global registry.
	DirectoryGlobal = "_global"

	// KeyDoguPublicKey contains the key to a dogu's public key.
	KeyDoguPublicKey = "public.pem"
)

Variables

This section is empty.

Functions

func Get added in v0.2.0

func Get(parent string, key string, client etcdClient) (string, error)

Get returns a configuration value from the current context, otherwise it returns an error. If the given key cannot be found a KeyNotFoundError is returned.

func IsKeyNotFoundError

func IsKeyNotFoundError(err error) bool

IsKeyNotFoundError returns true if the given error is a or contains a registry keyNotFoundError, otherwise false. It returns false if the given error is nil.

Types

type ConfigurationContext

type ConfigurationContext interface {
	// Set sets a configuration value in current context
	Set(key, value string) error
	// SetWithLifetime sets a configuration value in current context with the given lifetime
	SetWithLifetime(key, value string, timeToLiveInSeconds int) error
	// Refresh resets the time to live of a key
	Refresh(key string, timeToLiveInSeconds int) error
	// Get returns a configuration value from the current context
	Get(key string) (string, error)
	// GetAll returns a map of key value pairs
	GetAll() (map[string]string, error)
	// Delete removes a configuration key and value from the current context
	Delete(key string) error
	// DeleteRecursive removes a configuration key or directory from the current context
	DeleteRecursive(key string) error
	// Exists returns true if configuration key exists in the current context
	Exists(key string) (bool, error)
	// RemoveAll remove all configuration keys
	RemoveAll() error
	// GetOrFalse return false and empty string when the configuration value does not exist.
	// Otherwise, return true and the configuration value, even when the configuration value is an empty string.
	GetOrFalse(key string) (bool, string, error)
}

ConfigurationContext is able to manage the configuration of a single context

type ConfigurationReader

type ConfigurationReader struct {
	Configuration ConfigurationContext
}

ConfigurationReader is a simple abstraction for reading and converting registry value

func NewConfigurationReader

func NewConfigurationReader(configuration ConfigurationContext) *ConfigurationReader

NewConfigurationReader creates a new ConfigurationReader

func (*ConfigurationReader) GetBool

func (configReader *ConfigurationReader) GetBool(key string) (bool, error)

GetBool reads the configuration value and converts it to a boolean. If the key could not be found, the function will return false.

func (*ConfigurationReader) GetInt

func (configReader *ConfigurationReader) GetInt(key string) (int, error)

GetInt reads the configuration value and converts it to an integer. If the key could not be found, the function will return 0.

func (*ConfigurationReader) GetString

func (configReader *ConfigurationReader) GetString(key string) (string, error)

GetString reads a string from registry

type DoguRegistry

type DoguRegistry interface {
	// Enable enables the given dogu
	Enable(dogu *core.Dogu) error
	// Register registeres the dogu on the registry
	Register(dogu *core.Dogu) error
	// Unregister unregisters the dogu on the registry
	Unregister(name string) error
	// Get returns the dogu which the given name
	Get(name string) (*core.Dogu, error)
	// GetAll returns all installed dogus
	GetAll() ([]*core.Dogu, error)
	// IsEnabled returns true if the dogu is installed
	IsEnabled(name string) (bool, error)
}

DoguRegistry manages dogus on a ecosystem

type MockRegistry deprecated

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

MockRegistry is a in memory implementation of the registry interface. This registry is only for testing purposes and should never be used in production environments.

Deprecated: MockRegistry exists for historical compatibility and should not be used. Use mocks.Registry instead.

func (*MockRegistry) BlueprintRegistry

func (mr *MockRegistry) BlueprintRegistry() ConfigurationContext

GlobalConfig returns a mock implementation of the global configuration context

func (*MockRegistry) DoguConfig

func (mr *MockRegistry) DoguConfig(dogu string) ConfigurationContext

DoguConfig returns a mock implementation of a dogu configuration context

func (*MockRegistry) DoguRegistry

func (mr *MockRegistry) DoguRegistry() DoguRegistry

DoguRegistry returns a mock implementation of the dogu registry

func (*MockRegistry) GlobalConfig

func (mr *MockRegistry) GlobalConfig() ConfigurationContext

GlobalConfig returns a mock implementation of the global configuration context

func (*MockRegistry) HostConfig

func (mr *MockRegistry) HostConfig(hostService string) ConfigurationContext

func (*MockRegistry) State

func (mr *MockRegistry) State(dogu string) State

State is currently not implemented and returns always nil

type Registry

type Registry interface {
	// GlobalConfig returns a ConfigurationContext for the global context
	GlobalConfig() ConfigurationContext
	// HostConfig returns a ConfigurationContext for the host context
	HostConfig(hostService string) ConfigurationContext
	// DoguConfig returns a ConfigurationContext for the given dogu
	DoguConfig(dogu string) ConfigurationContext
	// State returns the state object for the given dogu
	State(dogu string) State
	// DoguRegistry returns an object which is able to manage dogus
	DoguRegistry() DoguRegistry
	// BlueprintRegistry to maintain a blueprint history
	BlueprintRegistry() ConfigurationContext
	// RootConfig returns a WatchConfigurationContext for the root context
	RootConfig() WatchConfigurationContext
}

Registry represents the main registry of a cloudogu ecosystem. The registry manage dogus, their configuration and their states.

func New

func New(configuration core.Registry) (Registry, error)

New creates a new registry

type State

type State interface {
	// Get returns the current state value
	Get() (string, error)
	// Set sets the state of the dogu
	Set(value string) error
	// Remove removes the state of the dogu
	Remove() error
}

State handles state related functions of a dogu

type WatchConfigurationContext added in v0.2.0

type WatchConfigurationContext interface {
	// Watch watches for changes of the provided key and sends the event through the channel
	Watch(ctx context.Context, key string, recursive bool, eventChannel chan *client.Response)
	// Get returns a configuration value from the current context
	Get(key string) (string, error)
	// GetChildrenPaths returns an array of all children keys of the given key
	GetChildrenPaths(key string) ([]string, error)
}

WatchConfigurationContext is just able to watch and query the configuration of a single context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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