storage

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: Apache-2.0, BSD-3-Clause, MIT Imports: 19 Imported by: 13

Documentation

Overview

Package storage contains logic around the Service Manager persistent storage

Index

Constants

This section is empty.

Variables

View Source
var ErrQueueClosed = errors.New("queue closed")

ErrQueueClosed error stating that the queue is closed

View Source
var ErrQueueFull = errors.New("queue is full")

ErrQueueFull error stating that the queue is full

Functions

func NewNotificationQueue added in v0.3.0

func NewNotificationQueue(size int) (*notificationQueue, error)

NewNotificationQueue returns new NotificationQueue with specific size

func NewSQLHealthIndicator added in v0.5.0

func NewSQLHealthIndicator(pingFunc PingFunc) (health.Indicator, error)

NewSQLHealthIndicator returns new health indicator for sql storage given a ping function

Types

type CreateAroundTxInterceptor added in v0.7.3

type CreateAroundTxInterceptor interface {
	AroundTxCreate(f InterceptCreateAroundTxFunc) InterceptCreateAroundTxFunc
}

CreateAroundTxInterceptor provides hooks on entity creation during AroundTx

type CreateAroundTxInterceptorChain added in v0.7.3

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

func (*CreateAroundTxInterceptorChain) AroundTxCreate added in v0.7.3

AroundTxCreate wraps the provided InterceptCreateAroundTxFunc into all the existing aroundTx funcs

type CreateAroundTxInterceptorProvider added in v0.7.3

type CreateAroundTxInterceptorProvider interface {
	web.Named
	Provide() CreateAroundTxInterceptor
}

type CreateInterceptor added in v0.2.0

type CreateInterceptor interface {
	CreateAroundTxInterceptor
	CreateOnTxInterceptor
}

CreateInterceptor provides hooks on entity creation both during AroundTx and OnTx

type CreateInterceptorChain added in v0.2.0

type CreateInterceptorChain struct {
	*CreateAroundTxInterceptorChain
	*CreateOnTxInterceptorChain
}

CreateInterceptorChain is an interceptor tha provides and chains a list of ordered interceptor providers.

type CreateInterceptorProvider added in v0.2.0

type CreateInterceptorProvider interface {
	web.Named
	Provide() CreateInterceptor
}

CreateInterceptorProvider provides CreateInterceptors for each request

type CreateOnTxInterceptor added in v0.7.3

type CreateOnTxInterceptor interface {
	OnTxCreate(f InterceptCreateOnTxFunc) InterceptCreateOnTxFunc
}

CreateOnTxInterceptor provides hooks on entity creation during OnTx

type CreateOnTxInterceptorChain added in v0.7.3

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

func (*CreateOnTxInterceptorChain) OnTxCreate added in v0.7.3

OnTxCreate wraps the provided InterceptCreateOnTxFunc into all the existing onTx funcs

type CreateOnTxInterceptorProvider added in v0.7.3

type CreateOnTxInterceptorProvider interface {
	web.Named
	Provide() CreateOnTxInterceptor
}

type DeleteAroundTxInterceptor added in v0.7.3

type DeleteAroundTxInterceptor interface {
	AroundTxDelete(f InterceptDeleteAroundTxFunc) InterceptDeleteAroundTxFunc
}

DeleteAroundTxInterceptor provides hooks on entity deletion during AroundTx

type DeleteAroundTxInterceptorChain added in v0.7.3

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

func (*DeleteAroundTxInterceptorChain) AroundTxDelete added in v0.7.3

AroundTxDelete wraps the provided InterceptDeleteAroundTxFunc into all the existing aroundTx funcs

type DeleteAroundTxInterceptorProvider added in v0.7.3

type DeleteAroundTxInterceptorProvider interface {
	web.Named
	Provide() DeleteAroundTxInterceptor
}

type DeleteInterceptor added in v0.2.0

type DeleteInterceptor interface {
	DeleteAroundTxInterceptor
	DeleteOnTxInterceptor
}

DeleteInterceptor provides hooks on entity deletion both during AroundTx and OnTx

type DeleteInterceptorChain added in v0.2.0

type DeleteInterceptorChain struct {
	*DeleteAroundTxInterceptorChain
	*DeleteOnTxInterceptorChain
}

DeleteInterceptorChain is an interceptor tha provides and chains a list of ordered interceptor providers.

type DeleteInterceptorProvider added in v0.2.0

type DeleteInterceptorProvider interface {
	web.Named
	Provide() DeleteInterceptor
}

DeleteInterceptorProvider provides DeleteInterceptors for each request

type DeleteOnTxInterceptor added in v0.7.3

type DeleteOnTxInterceptor interface {
	OnTxDelete(f InterceptDeleteOnTxFunc) InterceptDeleteOnTxFunc
}

DeleteOnTxInterceptor provides hooks on entity deletion during OnTx

type DeleteOnTxInterceptorChain added in v0.7.3

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

func (*DeleteOnTxInterceptorChain) OnTxDelete added in v0.7.3

OnTxDelete wraps the provided InterceptDeleteOnTxFunc into all the existing onTx funcs

type DeleteOnTxInterceptorProvider added in v0.7.3

type DeleteOnTxInterceptorProvider interface {
	web.Named
	Provide() DeleteOnTxInterceptor
}

type Entity added in v0.2.0

type Entity interface {
	GetID() string
	ToObject() (types.Object, error)
	FromObject(object types.Object) (Entity, error)
	NewLabel(id, entityID, key, value string) Label
}

type InterceptCreateAroundTxFunc added in v0.2.0

type InterceptCreateAroundTxFunc func(ctx context.Context, obj types.Object) (types.Object, error)

InterceptCreateAroundTxFunc hook for entity creation outside of transaction

type InterceptCreateOnTxFunc added in v0.2.0

type InterceptCreateOnTxFunc func(ctx context.Context, txStorage Repository, obj types.Object) (types.Object, error)

InterceptCreateOnTxFunc hook for entity creation in transaction

type InterceptDeleteAroundTxFunc added in v0.2.0

type InterceptDeleteAroundTxFunc func(ctx context.Context, deletionCriteria ...query.Criterion) error

InterceptDeleteAroundTxFunc hook for entity deletion outside of transaction

type InterceptDeleteOnTxFunc added in v0.2.0

type InterceptDeleteOnTxFunc func(ctx context.Context, txStorage Repository, objects types.ObjectList, deletionCriteria ...query.Criterion) error

InterceptDeleteOnTxFunc hook for entity deletion in transaction

type InterceptUpdateAroundTxFunc added in v0.2.0

type InterceptUpdateAroundTxFunc func(ctx context.Context, newObj types.Object, labelChanges ...*types.LabelChange) (types.Object, error)

InterceptUpdateAroundTxFunc hook for entity update outside of transaction

type InterceptUpdateOnTxFunc added in v0.2.0

type InterceptUpdateOnTxFunc func(ctx context.Context, txStorage Repository, oldObj, newObj types.Object, labelChanges ...*types.LabelChange) (types.Object, error)

InterceptUpdateOnTxFunc hook for entity update in transaction

type InterceptableTransactionalRepository added in v0.2.0

type InterceptableTransactionalRepository struct {
	RawRepository TransactionalRepository
	// contains filtered or unexported fields
}

func NewInterceptableTransactionalRepository added in v0.2.0

func NewInterceptableTransactionalRepository(repository TransactionalRepository) *InterceptableTransactionalRepository

func (*InterceptableTransactionalRepository) AddCreateAroundTxInterceptorProvider added in v0.7.3

func (itr *InterceptableTransactionalRepository) AddCreateAroundTxInterceptorProvider(objectType types.ObjectType, provider CreateAroundTxInterceptorProvider, order InterceptorOrder)

func (*InterceptableTransactionalRepository) AddCreateInterceptorProvider added in v0.2.0

func (itr *InterceptableTransactionalRepository) AddCreateInterceptorProvider(objectType types.ObjectType, provider CreateInterceptorProvider, order InterceptorOrder)

func (*InterceptableTransactionalRepository) AddCreateOnTxInterceptorProvider added in v0.7.3

func (itr *InterceptableTransactionalRepository) AddCreateOnTxInterceptorProvider(objectType types.ObjectType, provider CreateOnTxInterceptorProvider, order InterceptorOrder)

func (*InterceptableTransactionalRepository) AddDeleteAroundTxInterceptorProvider added in v0.7.3

func (itr *InterceptableTransactionalRepository) AddDeleteAroundTxInterceptorProvider(objectType types.ObjectType, provider DeleteAroundTxInterceptorProvider, order InterceptorOrder)

func (*InterceptableTransactionalRepository) AddDeleteInterceptorProvider added in v0.2.0

func (itr *InterceptableTransactionalRepository) AddDeleteInterceptorProvider(objectType types.ObjectType, provider DeleteInterceptorProvider, order InterceptorOrder)

func (*InterceptableTransactionalRepository) AddDeleteOnTxInterceptorProvider added in v0.7.3

func (itr *InterceptableTransactionalRepository) AddDeleteOnTxInterceptorProvider(objectType types.ObjectType, provider DeleteOnTxInterceptorProvider, order InterceptorOrder)

func (*InterceptableTransactionalRepository) AddUpdateAroundTxInterceptorProvider added in v0.7.3

func (itr *InterceptableTransactionalRepository) AddUpdateAroundTxInterceptorProvider(objectType types.ObjectType, provider UpdateAroundTxInterceptorProvider, order InterceptorOrder)

func (*InterceptableTransactionalRepository) AddUpdateInterceptorProvider added in v0.2.0

func (itr *InterceptableTransactionalRepository) AddUpdateInterceptorProvider(objectType types.ObjectType, provider UpdateInterceptorProvider, order InterceptorOrder)

func (*InterceptableTransactionalRepository) AddUpdateOnTxInterceptorProvider added in v0.7.3

func (itr *InterceptableTransactionalRepository) AddUpdateOnTxInterceptorProvider(objectType types.ObjectType, provider UpdateOnTxInterceptorProvider, order InterceptorOrder)

func (*InterceptableTransactionalRepository) Count added in v0.6.0

func (itr *InterceptableTransactionalRepository) Count(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (int, error)

func (*InterceptableTransactionalRepository) Create added in v0.2.0

func (*InterceptableTransactionalRepository) Delete added in v0.2.0

func (itr *InterceptableTransactionalRepository) Delete(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) error

func (*InterceptableTransactionalRepository) DeleteReturning added in v0.9.4

func (itr *InterceptableTransactionalRepository) DeleteReturning(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

func (*InterceptableTransactionalRepository) Get added in v0.2.0

func (*InterceptableTransactionalRepository) GetForUpdate added in v0.11.1

func (itr *InterceptableTransactionalRepository) GetForUpdate(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.Object, error)

func (*InterceptableTransactionalRepository) InTransaction added in v0.2.0

func (itr *InterceptableTransactionalRepository) InTransaction(ctx context.Context, f func(ctx context.Context, storage Repository) error) error

func (*InterceptableTransactionalRepository) List added in v0.2.0

func (*InterceptableTransactionalRepository) ListNoLabels added in v0.11.2

func (itr *InterceptableTransactionalRepository) ListNoLabels(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

func (*InterceptableTransactionalRepository) Update added in v0.2.0

func (itr *InterceptableTransactionalRepository) Update(ctx context.Context, obj types.Object, labelChanges types.LabelChanges, criteria ...query.Criterion) (types.Object, error)

func (*InterceptableTransactionalRepository) UpdateLabels added in v0.11.2

func (itr *InterceptableTransactionalRepository) UpdateLabels(ctx context.Context, objectType types.ObjectType, objectID string, labelChanges types.LabelChanges, criteria ...query.Criterion) error

type InterceptorOrder added in v0.2.0

type InterceptorOrder struct {
	OnTxPosition     InterceptorPosition
	AroundTxPosition InterceptorPosition
}

type InterceptorPosition added in v0.2.0

type InterceptorPosition struct {
	PositionType PositionType
	Name         string
}

type KeyStore added in v0.3.3

type KeyStore interface {
	// GetEncryptionKey returns the encryption key from the storage after applying the specified transformation function
	GetEncryptionKey(ctx context.Context, transformationFunc func(context.Context, []byte, []byte) ([]byte, error)) ([]byte, error)

	// SetEncryptionKey sets the provided encryption key in the KeyStore after applying the specified transformation function
	SetEncryptionKey(ctx context.Context, key []byte, transformationFunc func(context.Context, []byte, []byte) ([]byte, error)) error
}

KeyStore interface for encryption key operations

type Label added in v0.2.0

type Label interface {
	GetKey() string
	GetValue() string
}

type Locker added in v0.10.0

type Locker interface {
	// Lock locks the storage so that only one process can acquire it. Returns an error if the process has already acquired the lock, but waits if the lock is acquired by different connection
	Lock(ctx context.Context) error

	// TryLock tries to lock the storage, if it is already locked it returns an error, that it is already locked and does not wait
	TryLock(ctx context.Context) error

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

Locker provides basic Lock/Unlock functionality

type LockerCreatorFunc added in v0.10.0

type LockerCreatorFunc func(advisoryIndex int) Locker

LockerCreatorFunc is a function building a storage.Locker with a specific advisory index

type NotificationCleaner added in v0.3.0

type NotificationCleaner struct {
	Storage  Repository
	Settings Settings
	// contains filtered or unexported fields
}

NotificationCleaner schedules a go routine which cleans old notifications

func (*NotificationCleaner) Start added in v0.3.0

func (nc *NotificationCleaner) Start(ctx context.Context, group *sync.WaitGroup) error

Start schedules the cleaner. It cannot be used concurrently.

type NotificationQueue added in v0.3.0

type NotificationQueue interface {
	// Enqueue adds a new notification for processing.
	Enqueue(notification *types.Notification) error

	// Channel returns the go channel with received notifications which has to be processed.
	Channel() <-chan *types.Notification

	// Close closes the queue.
	Close()

	// ID returns unique queue identifier
	ID() string
}

NotificationQueue is used for receiving notifications

type NotificationSettings added in v0.3.0

type NotificationSettings struct {
	QueuesSize           int           `mapstructure:"queues_size" description:"maximum number of notifications queued for sending to a client"`
	MinReconnectInterval time.Duration `mapstructure:"min_reconnect_interval" description:"minimum timeout between storage listen reconnects"`
	MaxReconnectInterval time.Duration `mapstructure:"max_reconnect_interval" description:"maximum timeout between storage listen reconnects"`
	CleanInterval        time.Duration `mapstructure:"clean_interval" description:"time between notification clean-up"`
	KeepFor              time.Duration `mapstructure:"keep_for" description:"the time to keep a notification in the storage"`
}

NotificationSettings type to be loaded from the environment

func DefaultNotificationSettings added in v0.3.0

func DefaultNotificationSettings() *NotificationSettings

DefaultNotificationSettings returns default values for Notificator settings

func (*NotificationSettings) Validate added in v0.3.0

func (s *NotificationSettings) Validate() error

Validate validates the Notification settings

type Notificator added in v0.3.0

type Notificator interface {
	// Start starts the Notificator
	Start(ctx context.Context, group *sync.WaitGroup) error

	// RegisterConsumer returns notification queue, last_known_revision and error if any.
	// Notifications after lastKnownRevision will be added to the queue.
	// If lastKnownRevision is -1 no previous notifications will be sent.
	// When consumer wants to stop listening for notifications it must unregister the notification queue.
	RegisterConsumer(consumer *types.Platform, lastKnownRevision int64) (NotificationQueue, int64, error)

	// UnregisterConsumer must be called to stop receiving notifications in the queue
	UnregisterConsumer(queue NotificationQueue) error

	// RegisterFilter adds a new filter which decides if a platform should receive given notification
	RegisterFilter(f ReceiversFilterFunc)
}

Notificator is used for receiving notifications for SM events

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 OrderedCreateAroundTxInterceptorProvider added in v0.7.3

type OrderedCreateAroundTxInterceptorProvider struct {
	InterceptorOrder
	CreateAroundTxInterceptorProvider
}

type OrderedCreateInterceptorProvider added in v0.2.0

type OrderedCreateInterceptorProvider struct {
	InterceptorOrder
	CreateInterceptorProvider
}

type OrderedCreateOnTxInterceptorProvider added in v0.7.3

type OrderedCreateOnTxInterceptorProvider struct {
	InterceptorOrder
	CreateOnTxInterceptorProvider
}

type OrderedDeleteAroundTxInterceptorProvider added in v0.7.3

type OrderedDeleteAroundTxInterceptorProvider struct {
	InterceptorOrder
	DeleteAroundTxInterceptorProvider
}

type OrderedDeleteInterceptorProvider added in v0.2.0

type OrderedDeleteInterceptorProvider struct {
	InterceptorOrder
	DeleteInterceptorProvider
}

type OrderedDeleteOnTxInterceptorProvider added in v0.7.3

type OrderedDeleteOnTxInterceptorProvider struct {
	InterceptorOrder
	DeleteOnTxInterceptorProvider
}

type OrderedUpdateAroundTxInterceptorProvider added in v0.7.3

type OrderedUpdateAroundTxInterceptorProvider struct {
	InterceptorOrder
	UpdateAroundTxInterceptorProvider
}

type OrderedUpdateInterceptorProvider added in v0.2.0

type OrderedUpdateInterceptorProvider struct {
	InterceptorOrder
	UpdateInterceptorProvider
}

type OrderedUpdateOnTxInterceptorProvider added in v0.7.3

type OrderedUpdateOnTxInterceptorProvider struct {
	InterceptorOrder
	UpdateOnTxInterceptorProvider
}

type PingFunc added in v0.1.2

type PingFunc func(context.Context) error

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

func (PingFunc) PingContext added in v0.5.0

func (mf PingFunc) PingContext(ctx context.Context) error

PingContext allows PingFunc to act as a Pinger

type Pinger added in v0.1.2

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

Pinger allows pinging the storage to check liveliness

type PositionType added in v0.2.0

type PositionType int

PositionType could be "before", "after" or "none"

const (
	// PositionNone states that a position is not set and the item will be appended
	PositionNone PositionType = iota

	// PositionBefore states that a position should be calculated before another position
	PositionBefore

	// PositionAfter states that a position should be calculated after another position
	PositionAfter
)

type ReceiversFilterFunc added in v0.3.3

type ReceiversFilterFunc func(recipients []*types.Platform, notification *types.Notification) (filteredRecipients []*types.Platform)

ReceiversFilterFunc filters recipients for a given notifications

type Repository added in v0.1.2

type Repository interface {
	// Create stores an object in SM DB
	Create(ctx context.Context, obj types.Object) (types.Object, error)

	// Get retrieves an object using the provided id from SM DB
	Get(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.Object, error)

	// GetForUpdate retrieves an object using the provided id from SM DB while also locking the retrieved rows
	GetForUpdate(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.Object, error)

	// List retrieves all object from SM DB
	List(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

	// ListNoLabels retrieves all object from SM DB without their labels
	ListNoLabels(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

	// Count retrieves number of objects of particular type in SM DB
	Count(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (int, error)

	// DeleteReturning deletes objects from SM DB
	DeleteReturning(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

	//Delete deletes objects from SM DB
	Delete(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) error

	// Update updates an object from SM DB
	Update(ctx context.Context, obj types.Object, labelChanges types.LabelChanges, criteria ...query.Criterion) (types.Object, error)

	// UpdateLabels updates the object labels in SM DB
	UpdateLabels(ctx context.Context, objectType types.ObjectType, objectID string, labelChanges types.LabelChanges, _ ...query.Criterion) error
}

type SQLHealthIndicator added in v0.5.0

type SQLHealthIndicator struct {
	*checkers.SQL
}

SQLHealthIndicator returns a new indicator for SQL storage

func (*SQLHealthIndicator) Name added in v0.5.0

func (i *SQLHealthIndicator) Name() string

Name returns the name of the storage component

type Settings

type Settings struct {
	URI                string                `mapstructure:"uri" description:"URI of the storage"`
	MigrationsURL      string                `mapstructure:"migrations_url" description:"location of a directory containing sql migrations scripts"`
	EncryptionKey      string                `mapstructure:"encryption_key" description:"key to use for encrypting database entries"`
	SkipSSLValidation  bool                  `mapstructure:"skip_ssl_validation" description:"whether to skip ssl verification when connecting to the storage"`
	MaxIdleConnections int                   `mapstructure:"max_idle_connections" description:"sets the maximum number of connections in the idle connection pool"`
	Notification       *NotificationSettings `mapstructure:"notification"`
	IntegrityProcessor security.IntegrityProcessor
}

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
	TransactionalRepository
	Pinger

	Introduce(entity Entity)
}

Storage interface provides entity-specific storages

type TransactionalEncryptingRepository added in v0.3.3

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

TransactionalEncryptingRepository is a TransactionalRepository with that also encrypts credentials of Secured objects before storing in the database them and decrypts credentials of Secured objects when reading them from the database

func NewEncryptingRepository added in v0.3.3

func NewEncryptingRepository(repository TransactionalRepository, encrypter security.Encrypter, key []byte) (*TransactionalEncryptingRepository, error)

NewEncryptingRepository creates a new TransactionalEncryptingRepository using the specified encrypter and encryption key

func (TransactionalEncryptingRepository) Count added in v0.6.0

func (er TransactionalEncryptingRepository) Count(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (int, error)

func (TransactionalEncryptingRepository) Create added in v0.3.3

func (er TransactionalEncryptingRepository) Create(ctx context.Context, obj types.Object) (types.Object, error)

func (TransactionalEncryptingRepository) Delete added in v0.3.3

func (er TransactionalEncryptingRepository) Delete(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) error

func (TransactionalEncryptingRepository) DeleteReturning added in v0.9.4

func (er TransactionalEncryptingRepository) DeleteReturning(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

func (TransactionalEncryptingRepository) Get added in v0.3.3

func (er TransactionalEncryptingRepository) Get(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.Object, error)

func (TransactionalEncryptingRepository) GetForUpdate added in v0.11.1

func (er TransactionalEncryptingRepository) GetForUpdate(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.Object, error)

func (*TransactionalEncryptingRepository) InTransaction added in v0.3.3

func (er *TransactionalEncryptingRepository) InTransaction(ctx context.Context, f func(ctx context.Context, storage Repository) error) error

InTransaction wraps repository passed in the transaction to also encypt/decrypt credentials

func (TransactionalEncryptingRepository) List added in v0.3.3

func (er TransactionalEncryptingRepository) List(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

func (TransactionalEncryptingRepository) ListNoLabels added in v0.11.2

func (er TransactionalEncryptingRepository) ListNoLabels(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

func (TransactionalEncryptingRepository) Update added in v0.3.3

func (er TransactionalEncryptingRepository) Update(ctx context.Context, obj types.Object, labelChanges types.LabelChanges, _ ...query.Criterion) (types.Object, error)

func (TransactionalEncryptingRepository) UpdateLabels added in v0.11.2

func (cr TransactionalEncryptingRepository) UpdateLabels(ctx context.Context, objectType types.ObjectType, objectID string, labelChanges types.LabelChanges, criteria ...query.Criterion) error

type TransactionalIntegrityRepository added in v0.11.0

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

TransactionalIntegrityRepository is a TransactionalRepository which also processes the integrity of Integral objects before storing and after fetching them from the database

func NewIntegrityRepository added in v0.11.0

func NewIntegrityRepository(repository TransactionalRepository, integrityProcessor security.IntegrityProcessor) *TransactionalIntegrityRepository

NewIntegrityRepository returns a new TransactionIntegrityRepository using the specified integrity processor

func (TransactionalIntegrityRepository) Count added in v0.11.0

func (cr TransactionalIntegrityRepository) Count(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (int, error)

func (TransactionalIntegrityRepository) Create added in v0.11.0

func (cr TransactionalIntegrityRepository) Create(ctx context.Context, obj types.Object) (types.Object, error)

func (TransactionalIntegrityRepository) Delete added in v0.11.0

func (cr TransactionalIntegrityRepository) Delete(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) error

func (TransactionalIntegrityRepository) DeleteReturning added in v0.11.0

func (cr TransactionalIntegrityRepository) DeleteReturning(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

func (TransactionalIntegrityRepository) Get added in v0.11.0

func (cr TransactionalIntegrityRepository) Get(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.Object, error)

func (TransactionalIntegrityRepository) GetForUpdate added in v0.11.1

func (cr TransactionalIntegrityRepository) GetForUpdate(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.Object, error)

func (*TransactionalIntegrityRepository) InTransaction added in v0.11.0

func (cr *TransactionalIntegrityRepository) InTransaction(ctx context.Context, f func(ctx context.Context, storage Repository) error) error

func (TransactionalIntegrityRepository) List added in v0.11.0

func (cr TransactionalIntegrityRepository) List(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

func (TransactionalIntegrityRepository) ListNoLabels added in v0.11.2

func (cr TransactionalIntegrityRepository) ListNoLabels(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)

func (TransactionalIntegrityRepository) Update added in v0.11.0

func (cr TransactionalIntegrityRepository) Update(ctx context.Context, obj types.Object, labelChanges types.LabelChanges, criteria ...query.Criterion) (types.Object, error)

func (TransactionalIntegrityRepository) UpdateLabels added in v0.11.2

func (cr TransactionalIntegrityRepository) UpdateLabels(ctx context.Context, objectType types.ObjectType, objectID string, labelChanges types.LabelChanges, criteria ...query.Criterion) error

type TransactionalRepository added in v0.2.0

type TransactionalRepository interface {
	Repository

	// 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 Repository) error) error
}

TransactionalRepository is a storage repository that can initiate a transaction

func InitializeWithSafeTermination added in v0.3.3

func InitializeWithSafeTermination(ctx context.Context, s Storage, settings *Settings, wg *sync.WaitGroup, decorators ...TransactionalRepositoryDecorator) (TransactionalRepository, error)

type TransactionalRepositoryDecorator added in v0.3.3

type TransactionalRepositoryDecorator func(TransactionalRepository) (TransactionalRepository, error)

TransactionalRepositoryDecorator allows decorating a TransactionalRepository

func DataIntegrityDecorator added in v0.11.0

func DataIntegrityDecorator(integrityProcessor security.IntegrityProcessor) TransactionalRepositoryDecorator

DataIntegrityDecorator decorates a repository to process the integrity of integral objects

func EncryptingDecorator added in v0.3.3

func EncryptingDecorator(ctx context.Context, encrypter security.Encrypter, keyStore KeyStore, locker Locker) TransactionalRepositoryDecorator

EncryptingDecorator creates a TransactionalRepositoryDecorator that can be used to add encrypting/decrypting logic to a TransactionalRepository

type UpdateAroundTxInterceptor added in v0.7.3

type UpdateAroundTxInterceptor interface {
	AroundTxUpdate(h InterceptUpdateAroundTxFunc) InterceptUpdateAroundTxFunc
}

UpdateAroundTxInterceptor provides hooks on entity update during AroundTx

type UpdateAroundTxInterceptorChain added in v0.7.3

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

func (*UpdateAroundTxInterceptorChain) AroundTxUpdate added in v0.7.3

AroundTxUpdate wraps the provided InterceptUpdateAroundTxFunc into all the existing aroundTx funcs

type UpdateAroundTxInterceptorProvider added in v0.7.3

type UpdateAroundTxInterceptorProvider interface {
	web.Named
	Provide() UpdateAroundTxInterceptor
}

type UpdateInterceptor added in v0.2.0

type UpdateInterceptor interface {
	UpdateAroundTxInterceptor
	UpdateOnTxInterceptor
}

UpdateInterceptor provides hooks on entity update

type UpdateInterceptorChain added in v0.2.0

type UpdateInterceptorChain struct {
	*UpdateAroundTxInterceptorChain
	*UpdateOnTxInterceptorChain
}

UpdateInterceptorChain is an interceptor tha provides and chains a list of ordered interceptor providers.

type UpdateInterceptorProvider added in v0.2.0

type UpdateInterceptorProvider interface {
	web.Named
	Provide() UpdateInterceptor
}

UpdateInterceptorProvider provides UpdateInterceptors for each request

type UpdateOnTxInterceptor added in v0.7.3

type UpdateOnTxInterceptor interface {
	OnTxUpdate(f InterceptUpdateOnTxFunc) InterceptUpdateOnTxFunc
}

UpdateOnTxInterceptor provides hooks on entity update during OnTx

type UpdateOnTxInterceptorChain added in v0.7.3

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

func (*UpdateOnTxInterceptorChain) OnTxUpdate added in v0.7.3

OnTxUpdate wraps the provided InterceptUpdateOnTxFunc into all the existing onTx funcs

type UpdateOnTxInterceptorProvider added in v0.7.3

type UpdateOnTxInterceptorProvider interface {
	web.Named
	Provide() UpdateOnTxInterceptor
}

Directories

Path Synopsis
notification_connection/notification_connectionfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
postgresfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
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