storage

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfKey = "storage"
)

Variables

This section is empty.

Functions

func RegisterDriver

func RegisterDriver(name string, cons Constructor)

RegisterDriver registers a storage driver.

func TestSubscription

func TestSubscription(s Subscribable) func(*testing.T, ...Event)

TestSubscription is a helper to test subscriptions.

Types

type Constructor

type Constructor func(context.Context) (Store, error)

Constructor is a constructor function for a storage driver.

type Event

type Event struct {
	Kind     EventKind
	PolicyID namer.ModuleID
}

Event is an event detected by the storage layer.

func NewEvent

func NewEvent(kind EventKind, policyID namer.ModuleID) Event

NewEvent creates a new storage event.

func (Event) String

func (evt Event) String() string

type EventKind

type EventKind int

EventKind identifies the kind of storage event such as addition or deletion.

const (
	EventAddOrUpdatePolicy EventKind = iota
	EventDeletePolicy
	EventNop
)

type InvalidPolicyError

type InvalidPolicyError struct {
	Message string
	Err     error
}

InvalidPolicyError is a custom error to signal that a policy is invalid.

func NewInvalidPolicyError

func NewInvalidPolicyError(err error, msg string, args ...interface{}) InvalidPolicyError

func (InvalidPolicyError) Error

func (ipe InvalidPolicyError) Error() string

func (InvalidPolicyError) Unwrap

func (ipe InvalidPolicyError) Unwrap() error

type MutableStore

type MutableStore interface {
	Store
	AddOrUpdate(context.Context, ...policy.Wrapper) error
	Delete(context.Context, ...namer.ModuleID) error
}

MutableStore is a store that allows mutations.

type Store

type Store interface {
	Subscribable
	// Driver is the name of the storage backend implementation.
	Driver() string
	// GetCompilationUnits gets the compilation units for the given module IDs.
	GetCompilationUnits(context.Context, ...namer.ModuleID) (map[namer.ModuleID]*policy.CompilationUnit, error)
	// GetDependents returns the dependents of the given modules.
	GetDependents(context.Context, ...namer.ModuleID) (map[namer.ModuleID][]namer.ModuleID, error)
	// GetPolicies returns the policies recorded in the store.
	GetPolicies(context.Context) ([]*policy.Wrapper, error)
}

Store is the common interface implemented by storage backends.

func New

func New(ctx context.Context) (Store, error)

New returns a storage driver implementation based on the configured driver.

type Subscribable

type Subscribable interface {
	// Subscribe adds a subscriber to listen for storage notifications.
	Subscribe(Subscriber)
	// Unsubscribe removes a subscriber.
	Unsubscribe(Subscriber)
}

Subscribable is an interface for managing subscriptions to storage events.

type Subscriber

type Subscriber interface {
	SubscriberID() string
	OnStorageEvent(...Event)
}

Subscriber is the interface implemented by storage subscribers.

type SubscriptionManager

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

func NewSubscriptionManager

func NewSubscriptionManager(ctx context.Context) *SubscriptionManager

func (*SubscriptionManager) NotifySubscribers

func (sm *SubscriptionManager) NotifySubscribers(events ...Event)

Notify sends the events to all subscribers.

func (*SubscriptionManager) Subscribe

func (sm *SubscriptionManager) Subscribe(s Subscriber)

func (*SubscriptionManager) Unsubscribe

func (sm *SubscriptionManager) Unsubscribe(s Subscriber)

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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