storage

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: Apache-2.0, BSD-3-Clause, MIT Imports: 9 Imported by: 0

Documentation

Overview

Package storage contains logic around the Service Manager persistent storage

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, storage Storage)

Register adds a storage with the given name

Types

type Broker

type Broker interface {
	// Create stores a broker in SM DB
	Create(ctx context.Context, broker *types.Broker) error

	// Get retrieves a broker using the provided id from SM DB
	Get(ctx context.Context, id string) (*types.Broker, error)

	// List retrieves all brokers from SM DB
	List(ctx context.Context) ([]*types.Broker, error)

	// Delete deletes a broker from SM DB
	Delete(ctx context.Context, id string) error

	// Update updates a broker from SM DB
	Update(ctx context.Context, broker *types.Broker) error
}

Broker interface for Broker db operations

type Credentials

type Credentials interface {
	// Get retrieves credentials using the provided username from SM DB
	Get(ctx context.Context, username string) (*types.Credentials, error)
}

Credentials interface for Credentials db operations

type HealthIndicator added in v0.1.1

type HealthIndicator struct {
	Pinger Pinger
}

HealthIndicator returns a new indicator for the storage

func (*HealthIndicator) Health added in v0.1.1

func (i *HealthIndicator) Health() *health.Health

Health returns the health of the storage component

func (*HealthIndicator) Name added in v0.1.1

func (i *HealthIndicator) Name() string

Name returns the name of the storage component

type OpenCloser added in v0.1.2

type OpenCloser interface {
	// Open initializes the storage, e.g. opens a connection to the underlying storage
	Open(options *Settings) error

	// Close clears resources associated with this storage, e.g. closes the connection the underlying storage
	Close() error
}

OpenCloser represents an openable and closeable storage

type PingFunc added in v0.1.2

type PingFunc func() error

PingFunc is an adapter that allows to use regular functions as Pinger

func (PingFunc) Ping added in v0.1.2

func (mf PingFunc) Ping() error

Run allows PingFunc to act as a Pinger

type Pinger added in v0.1.2

type Pinger interface {
	// Ping verifies a connection to the database is still alive, establishing a connection if necessary.
	Ping() error
}

Pinger allows pinging the storage to check liveliness

type Platform

type Platform interface {
	// Create stores a platform in SM DB
	Create(ctx context.Context, platform *types.Platform) error

	// Get retrieves a platform using the provided id from SM DB
	Get(ctx context.Context, id string) (*types.Platform, error)

	// List retrieves all platforms from SM DB
	List(ctx context.Context) ([]*types.Platform, error)

	// Delete deletes a platform from SM DB
	Delete(ctx context.Context, id string) error

	// Update updates a platform from SM DB
	Update(ctx context.Context, platform *types.Platform) error
}

Platform interface for Platform DB operations

type Repository added in v0.1.2

type Repository interface {
	Warehouse

	// InTransaction initiates a transaction and allows passing a function to be executed within the transaction
	InTransaction(ctx context.Context, f func(ctx context.Context, storage Warehouse) error) error
}

Repository is a storage warehouse that can initiate a transaction

type Security

type Security interface {
	// Lock locks the storage so that only one process can manipulate the encryption key.
	// Returns an error if the process has already acquired the lock
	Lock(ctx context.Context) error

	// Unlock releases the acquired lock.
	Unlock(ctx context.Context) error

	// Fetcher provides means to obtain the encryption key
	Fetcher() security.KeyFetcher

	// Setter provides means to change the encryption  key
	Setter() security.KeySetter
}

Security interface for encryption key operations

type ServiceOffering added in v0.1.2

type ServiceOffering interface {
	// Create stores a service offering in SM DB
	Create(ctx context.Context, serviceOffering *types.ServiceOffering) error

	// Get retrieves a service offering using the provided id from SM DB
	Get(ctx context.Context, id string) (*types.ServiceOffering, error)

	// ListByCatalogName retrieves all service offerings from SM DB that match the specified catalog name
	ListByCatalogName(ctx context.Context, name string) ([]*types.ServiceOffering, error)

	// ListWithServicePlansByBrokerID retrieves all service offerings with their service plans from SM DB that match the specified broker ID
	ListWithServicePlansByBrokerID(ctx context.Context, brokerID string) ([]*types.ServiceOffering, error)

	// List retrieves all service offerings from SM DB
	List(ctx context.Context) ([]*types.ServiceOffering, error)

	// Delete deletes a service offering from SM DB
	Delete(ctx context.Context, id string) error

	// Update updates a service offering from SM DB
	Update(ctx context.Context, serviceOffering *types.ServiceOffering) error
}

ServiceOffering instance for Service Offerings DB operations

type ServicePlan added in v0.1.2

type ServicePlan interface {
	// Create stores a service service_plan in SM DB
	Create(ctx context.Context, servicePlan *types.ServicePlan) error

	// Get retrieves a service service_plan using the provided id from SM DB
	Get(ctx context.Context, id string) (*types.ServicePlan, error)

	// ListByCatalogName retrieves all service plans from SM DB that match the specified catalog name
	ListByCatalogName(ctx context.Context, name string) ([]*types.ServicePlan, error)

	// List retrieves all service plans from SM DB
	List(ctx context.Context) ([]*types.ServicePlan, error)

	// Delete deletes a service service_plan from SM DB
	Delete(ctx context.Context, id string) error

	// Update updates a service service_plan from SM DB
	Update(ctx context.Context, servicePlan *types.ServicePlan) error
}

ServiceOffering instance for Service Plan DB operations

type Settings

type Settings struct {
	URI               string
	MigrationsURL     string `mapstructure:"migrations_url"`
	EncryptionKey     string `mapstructure:"encryption_key"`
	SkipSSLValidation bool   `mapstructure:"skip_ssl_validation"`
}

Settings type to be loaded from the environment

func DefaultSettings

func DefaultSettings() *Settings

DefaultSettings returns default values for storage settings

func (*Settings) Validate

func (s *Settings) Validate() error

Validate validates the storage settings

type Storage

type Storage interface {
	OpenCloser
	Pinger
	Repository
}

Storage interface provides entity-specific storages

func Use

func Use(ctx context.Context, name string, options *Settings) (Storage, error)

Use specifies the storage for the given name Returns the storage ready to be used and an error if one occurred during initialization Upon context.Done signal the storage will be closed

type Warehouse added in v0.1.2

type Warehouse interface {
	// Broker provides access to service broker db operations
	Broker() Broker

	// ServiceOffering provides access to service offering db operations
	ServiceOffering() ServiceOffering

	// ServicePlan provides access to service plan db operations
	ServicePlan() ServicePlan

	// Platform provides access to platform db operations
	Platform() Platform

	// Credentials provides access to credentials db operations
	Credentials() Credentials

	// Security provides access to encryption key management
	Security() Security
}

Warehouse contains the Service Manager data access object providers

Directories

Path Synopsis
Package postgres implements the Service Manager storage interfaces for Postgresql Repository
Package postgres implements the Service Manager storage interfaces for Postgresql Repository
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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