Documentation
¶
Overview ¶
Package storage contains logic around the Service Manager persistent storage
Index ¶
- func HasStorage(name string) bool
- func Register(name string, storage Storage)
- type CreateInterceptor
- type CreateInterceptorChain
- type CreateInterceptorProvider
- type Credentials
- type DeleteInterceptor
- type DeleteInterceptorChain
- type DeleteInterceptorProvider
- type Entity
- type HealthIndicator
- type InterceptCreateAroundTxFunc
- type InterceptCreateOnTxFunc
- type InterceptDeleteAroundTxFunc
- type InterceptDeleteOnTxFunc
- type InterceptUpdateAroundTxFunc
- type InterceptUpdateOnTxFunc
- type InterceptableTransactionalRepository
- func (itr *InterceptableTransactionalRepository) AddCreateInterceptorProvider(objectType types.ObjectType, provider OrderedCreateInterceptorProvider)
- func (itr *InterceptableTransactionalRepository) AddDeleteInterceptorProvider(objectType types.ObjectType, provider OrderedDeleteInterceptorProvider)
- func (itr *InterceptableTransactionalRepository) AddUpdateInterceptorProvider(objectType types.ObjectType, provider OrderedUpdateInterceptorProvider)
- func (itr *InterceptableTransactionalRepository) Create(ctx context.Context, obj types.Object) (string, error)
- func (itr *InterceptableTransactionalRepository) Credentials() Credentials
- func (itr *InterceptableTransactionalRepository) Delete(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)
- func (itr *InterceptableTransactionalRepository) Get(ctx context.Context, objectType types.ObjectType, id string) (types.Object, error)
- func (itr *InterceptableTransactionalRepository) InTransaction(ctx context.Context, f func(ctx context.Context, storage Repository) error) error
- func (itr *InterceptableTransactionalRepository) List(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)
- func (itr *InterceptableTransactionalRepository) Security() Security
- func (itr *InterceptableTransactionalRepository) Update(ctx context.Context, obj types.Object, labelChanges ...*query.LabelChange) (types.Object, error)
- type InterceptorOrder
- type InterceptorPosition
- type Label
- type Named
- type OpenCloser
- type OrderedCreateInterceptorProvider
- type OrderedDeleteInterceptorProvider
- type OrderedUpdateInterceptorProvider
- type PingFunc
- type Pinger
- type PositionType
- type Repository
- type Security
- type Settings
- type Storage
- type TransactionalRepository
- type UpdateContext
- type UpdateInterceptor
- type UpdateInterceptorChain
- type UpdateInterceptorProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasStorage ¶ added in v0.2.0
HasStorage check whether storage with the given name is registered
Types ¶
type CreateInterceptor ¶ added in v0.2.0
type CreateInterceptor interface { AroundTxCreate(h InterceptCreateAroundTxFunc) InterceptCreateAroundTxFunc OnTxCreate(f InterceptCreateOnTxFunc) InterceptCreateOnTxFunc }
CreateInterceptor provides hooks on entity creation
type CreateInterceptorChain ¶ added in v0.2.0
type CreateInterceptorChain struct {
// contains filtered or unexported fields
}
func (*CreateInterceptorChain) AroundTxCreate ¶ added in v0.2.0
func (c *CreateInterceptorChain) AroundTxCreate(f InterceptCreateAroundTxFunc) InterceptCreateAroundTxFunc
func (*CreateInterceptorChain) Name ¶ added in v0.2.0
func (c *CreateInterceptorChain) Name() string
func (*CreateInterceptorChain) OnTxCreate ¶ added in v0.2.0
func (c *CreateInterceptorChain) OnTxCreate(f InterceptCreateOnTxFunc) InterceptCreateOnTxFunc
type CreateInterceptorProvider ¶ added in v0.2.0
type CreateInterceptorProvider interface { Named Provide() CreateInterceptor }
CreateInterceptorProvider provides CreateInterceptors for each request
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 DeleteInterceptor ¶ added in v0.2.0
type DeleteInterceptor interface { AroundTxDelete(h InterceptDeleteAroundTxFunc) InterceptDeleteAroundTxFunc OnTxDelete(f InterceptDeleteOnTxFunc) InterceptDeleteOnTxFunc }
DeleteInterceptor provides hooks on entity deletion
type DeleteInterceptorChain ¶ added in v0.2.0
type DeleteInterceptorChain struct {
// contains filtered or unexported fields
}
func (*DeleteInterceptorChain) AroundTxDelete ¶ added in v0.2.0
func (d *DeleteInterceptorChain) AroundTxDelete(f InterceptDeleteAroundTxFunc) InterceptDeleteAroundTxFunc
func (*DeleteInterceptorChain) Name ¶ added in v0.2.0
func (d *DeleteInterceptorChain) Name() string
func (*DeleteInterceptorChain) OnTxDelete ¶ added in v0.2.0
func (d *DeleteInterceptorChain) OnTxDelete(f InterceptDeleteOnTxFunc) InterceptDeleteOnTxFunc
type DeleteInterceptorProvider ¶ added in v0.2.0
type DeleteInterceptorProvider interface { Named Provide() DeleteInterceptor }
DeleteInterceptorProvider provides DeleteInterceptorChain for each request
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 InterceptCreateAroundTxFunc ¶ added in v0.2.0
InterceptCreateAroundTxFunc hook for entity creation outside of transaction
type InterceptCreateOnTxFunc ¶ added in v0.2.0
type InterceptCreateOnTxFunc func(ctx context.Context, txStorage Repository, newObject 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) (types.ObjectList, error)
InterceptDeleteAroundTxFunc hook for entity deletion outside of transaction
type InterceptDeleteOnTxFunc ¶ added in v0.2.0
type InterceptDeleteOnTxFunc func(ctx context.Context, txStorage Repository, deletionCriteria ...query.Criterion) (types.ObjectList, error)
InterceptDeleteOnTxFunc hook for entity deletion in transaction
type InterceptUpdateAroundTxFunc ¶ added in v0.2.0
type InterceptUpdateAroundTxFunc func(ctx context.Context, obj types.Object, labelChanges ...*query.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, obj types.Object, labelChanges ...*query.LabelChange) (types.Object, error)
InterceptUpdateOnTxFunc hook for entity update in transaction
type InterceptableTransactionalRepository ¶ added in v0.2.0
type InterceptableTransactionalRepository struct {
// contains filtered or unexported fields
}
func NewInterceptableTransactionalRepository ¶ added in v0.2.0
func NewInterceptableTransactionalRepository(repository TransactionalRepository, encrypter security.Encrypter) *InterceptableTransactionalRepository
func (*InterceptableTransactionalRepository) AddCreateInterceptorProvider ¶ added in v0.2.0
func (itr *InterceptableTransactionalRepository) AddCreateInterceptorProvider(objectType types.ObjectType, provider OrderedCreateInterceptorProvider)
func (*InterceptableTransactionalRepository) AddDeleteInterceptorProvider ¶ added in v0.2.0
func (itr *InterceptableTransactionalRepository) AddDeleteInterceptorProvider(objectType types.ObjectType, provider OrderedDeleteInterceptorProvider)
func (*InterceptableTransactionalRepository) AddUpdateInterceptorProvider ¶ added in v0.2.0
func (itr *InterceptableTransactionalRepository) AddUpdateInterceptorProvider(objectType types.ObjectType, provider OrderedUpdateInterceptorProvider)
func (*InterceptableTransactionalRepository) Credentials ¶ added in v0.2.0
func (itr *InterceptableTransactionalRepository) Credentials() Credentials
func (*InterceptableTransactionalRepository) Delete ¶ added in v0.2.0
func (itr *InterceptableTransactionalRepository) Delete(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)
func (*InterceptableTransactionalRepository) Get ¶ added in v0.2.0
func (itr *InterceptableTransactionalRepository) Get(ctx context.Context, objectType types.ObjectType, id string) (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 (itr *InterceptableTransactionalRepository) List(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error)
func (*InterceptableTransactionalRepository) Security ¶ added in v0.2.0
func (itr *InterceptableTransactionalRepository) Security() Security
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 Named ¶ added in v0.2.0
type Named interface {
Name() string
}
Named interface for named entities
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 OrderedCreateInterceptorProvider ¶ added in v0.2.0
type OrderedCreateInterceptorProvider struct { InterceptorOrder CreateInterceptorProvider }
type OrderedDeleteInterceptorProvider ¶ added in v0.2.0
type OrderedDeleteInterceptorProvider struct { InterceptorOrder DeleteInterceptorProvider }
type OrderedUpdateInterceptorProvider ¶ added in v0.2.0
type OrderedUpdateInterceptorProvider struct { InterceptorOrder UpdateInterceptorProvider }
type PingFunc ¶ added in v0.1.2
type PingFunc func() error
PingFunc is an adapter that allows to use regular functions as 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 PositionType ¶ added in v0.2.0
type PositionType string
PositionType could be "before", "after" or "none"
const ( // PositionNone states that a position is not set and the item will be appended PositionNone PositionType = "none" // PositionBefore states that a position should be calculated before another position PositionBefore PositionType = "before" // PositionAfter states that a position should be calculated after another position PositionAfter PositionType = "after" )
type Repository ¶ added in v0.1.2
type Repository interface { // Create stores a broker in SM DB Create(ctx context.Context, obj types.Object) (string, error) // Get retrieves a broker using the provided id from SM DB Get(ctx context.Context, objectType types.ObjectType, id string) (types.Object, error) // List retrieves all brokers from SM DB List(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error) // Delete deletes a broker from SM DB Delete(ctx context.Context, objectType types.ObjectType, criteria ...query.Criterion) (types.ObjectList, error) // Update updates a broker from SM DB Update(ctx context.Context, obj types.Object, labelChanges ...*query.LabelChange) (types.Object, error) Credentials() Credentials Security() Security }
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 `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"` }
Settings type to be loaded from the environment
func DefaultSettings ¶
func DefaultSettings() *Settings
DefaultSettings returns default values for storage settings
type Storage ¶
type Storage interface { OpenCloser Pinger TransactionalRepository Introduce(entity Entity) }
Storage interface provides entity-specific storages
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
type UpdateContext ¶ added in v0.2.0
type UpdateContext struct { Object types.Object ObjectChanges []byte LabelChanges []*query.LabelChange }
UpdateContext provides changes done by the update operation
type UpdateInterceptor ¶ added in v0.2.0
type UpdateInterceptor interface { AroundTxUpdate(h InterceptUpdateAroundTxFunc) InterceptUpdateAroundTxFunc OnTxUpdate(f InterceptUpdateOnTxFunc) InterceptUpdateOnTxFunc }
UpdateInterceptor provides hooks on entity update
type UpdateInterceptorChain ¶ added in v0.2.0
type UpdateInterceptorChain struct {
// contains filtered or unexported fields
}
func (*UpdateInterceptorChain) AroundTxUpdate ¶ added in v0.2.0
func (u *UpdateInterceptorChain) AroundTxUpdate(f InterceptUpdateAroundTxFunc) InterceptUpdateAroundTxFunc
func (*UpdateInterceptorChain) Name ¶ added in v0.2.0
func (u *UpdateInterceptorChain) Name() string
func (*UpdateInterceptorChain) OnTxUpdate ¶ added in v0.2.0
func (u *UpdateInterceptorChain) OnTxUpdate(f InterceptUpdateOnTxFunc) InterceptUpdateOnTxFunc
type UpdateInterceptorProvider ¶ added in v0.2.0
type UpdateInterceptorProvider interface { Named Provide() UpdateInterceptor }
UpdateInterceptorProvider provides UpdateInterceptors for each request
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
postgresfakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
Code generated by counterfeiter.
|
Code generated by counterfeiter. |