Documentation ¶
Index ¶
- Constants
- func RegisterDriver(name string, cons Constructor)
- func Reload(ctx context.Context, rs Reloadable) error
- func TestSubscription(s Subscribable) func(*testing.T, time.Duration, ...Event)
- type BinaryStore
- type Conf
- type Constructor
- type Event
- type EventKind
- type Instrumented
- type InvalidPolicyError
- type InvalidSchemaError
- type MutableStore
- type Reloadable
- type RepoStats
- type SourceStore
- type Store
- type Subscribable
- type Subscriber
- type SubscriptionManager
Constants ¶
const ConfKey = "storage"
Variables ¶
This section is empty.
Functions ¶
func RegisterDriver ¶
func RegisterDriver(name string, cons Constructor)
RegisterDriver registers a storage driver.
func TestSubscription ¶
TestSubscription is a helper to test subscriptions.
Types ¶
type BinaryStore ¶ added in v0.20.0
type BinaryStore interface { Store // GetPolicySet gets the compiled policy set identified by the given module ID. GetPolicySet(context.Context, namer.ModuleID) (*runtimev1.RunnablePolicySet, error) }
BinaryStore is implemented by stores that have pre-compiled policies in binary format.
type Conf ¶
type Conf struct {
// contains filtered or unexported fields
}
Conf is required configuration for storage. +desc=This section is required. The field driver must be set to indicate which driver to use.
type Constructor ¶
Constructor is a constructor function for a storage driver.
type Event ¶
Event is an event detected by the storage layer.
func NewPolicyEvent ¶ added in v0.11.0
NewPolicyEvent creates a new storage event for a policy.
func NewSchemaEvent ¶ added in v0.11.0
NewSchemaEvent creates a new storage event for a schema.
type EventKind ¶
type EventKind int
EventKind identifies the kind of storage event such as addition or deletion.
type Instrumented ¶ added in v0.15.0
Instrumented stores expose repository stats.
type InvalidPolicyError ¶
InvalidPolicyError is a custom error to signal that a policy is invalid.
func NewInvalidPolicyError ¶
func NewInvalidPolicyError(err error, msg string, args ...any) InvalidPolicyError
func (InvalidPolicyError) Error ¶
func (ipe InvalidPolicyError) Error() string
func (InvalidPolicyError) Unwrap ¶
func (ipe InvalidPolicyError) Unwrap() error
type InvalidSchemaError ¶ added in v0.12.0
InvalidSchemaError is a custom error to signal that a schema is invalid.
func NewInvalidSchemaError ¶ added in v0.12.0
func NewInvalidSchemaError(err error, msg string, args ...any) InvalidSchemaError
func (InvalidSchemaError) Error ¶ added in v0.12.0
func (ise InvalidSchemaError) Error() string
func (InvalidSchemaError) Unwrap ¶ added in v0.12.0
func (ise InvalidSchemaError) Unwrap() error
type MutableStore ¶
type MutableStore interface { Store AddOrUpdate(context.Context, ...policy.Wrapper) error AddOrUpdateSchema(context.Context, ...*schemav1.Schema) error DeleteSchema(context.Context, ...string) error Delete(context.Context, ...namer.ModuleID) error }
MutableStore is a store that allows mutations.
type Reloadable ¶ added in v0.20.0
Reloadable stores allow reloading their contents.
type SourceStore ¶ added in v0.20.0
type SourceStore interface { Store Subscribable // 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) // LoadPolicy loads the given policy from the store LoadPolicy(context.Context, ...string) ([]*policy.Wrapper, error) }
SourceStore is implemented by stores that have policies in their source format (uncompiled).
type Store ¶
type Store interface { // Driver is the name of the storage backend implementation. Driver() string // ListPolicyIDs returns the policy IDs in the store ListPolicyIDs(context.Context) ([]string, error) // ListSchemaIDs returns the schema ids in the store ListSchemaIDs(context.Context) ([]string, error) // LoadSchema loads the given schema from the store. LoadSchema(context.Context, string) (io.ReadCloser, error) }
Store is the common interface implemented by storage backends.
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 ¶
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)