storage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2018 License: Apache-2.0, BSD-3-Clause, MIT Imports: 6 Imported by: 13

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)

	// GetAll retrieves all brokers from SM DB
	GetAll(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 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)

	// GetAll retrieves all platforms from SM DB
	GetAll(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 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 Settings

type Settings struct {
	URI string
}

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 {
	// Open initializes the storage, e.g. opens a connection to the underlying storage
	Open(uri string, encryptionKey []byte) error

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

	// Ping verifies a connection to the database is still alive, establishing a connection if necessary.
	Ping() error

	// Broker provides access to service broker db operations
	Broker() Broker

	// 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
}

Storage interface provides entity-specific storages

func Use

func Use(ctx context.Context, name string, uri string, encryptionKey []byte) (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

Directories

Path Synopsis
Package postgres implements the Service Manager storage interfaces for Postgresql Storage Package postgres implements the Service Manager storage interfaces for Postgresql Storage
Package postgres implements the Service Manager storage interfaces for Postgresql Storage Package postgres implements the Service Manager storage interfaces for Postgresql Storage
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