Documentation ¶
Index ¶
- type Backend
- func (b *Backend) DeleteCAS(_ context.Context, id *pbresource.ID, version string) error
- func (b *Backend) List(_ context.Context, _ storage.ReadConsistency, resType storage.UnversionedType, ...) ([]*pbresource.Resource, error)
- func (b *Backend) ListByOwner(_ context.Context, id *pbresource.ID) ([]*pbresource.Resource, error)
- func (b *Backend) Read(_ context.Context, _ storage.ReadConsistency, id *pbresource.ID) (*pbresource.Resource, error)
- func (b *Backend) Run(ctx context.Context)
- func (b *Backend) WatchList(_ context.Context, resType storage.UnversionedType, ...) (storage.Watch, error)
- func (b *Backend) WriteCAS(_ context.Context, res *pbresource.Resource) (*pbresource.Resource, error)
- type Restoration
- type Snapshot
- type Store
- func (s *Store) DeleteCAS(id *pbresource.ID, vsn string) error
- func (s *Store) List(typ storage.UnversionedType, ten *pbresource.Tenancy, namePrefix string) ([]*pbresource.Resource, error)
- func (s *Store) ListByOwner(id *pbresource.ID) ([]*pbresource.Resource, error)
- func (s *Store) Read(id *pbresource.ID) (*pbresource.Resource, error)
- func (s *Store) Restore() (*Restoration, error)
- func (s *Store) Run(ctx context.Context)
- func (s *Store) Snapshot() (*Snapshot, error)
- func (s *Store) WatchList(typ storage.UnversionedType, ten *pbresource.Tenancy, namePrefix string) (*Watch, error)
- func (s *Store) WriteCAS(res *pbresource.Resource, vsn string) error
- type Watch
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
Backend is a purely in-memory storage backend implementation.
func NewBackend ¶
NewBackend returns a purely in-memory storage backend. It's suitable for testing and development mode, but should NOT be used in production as it has no support for durable persistence, so all of your data will be lost when the process restarts or crashes.
You must call Run before using the backend.
func (*Backend) List ¶
func (b *Backend) List(_ context.Context, _ storage.ReadConsistency, resType storage.UnversionedType, tenancy *pbresource.Tenancy, namePrefix string) ([]*pbresource.Resource, error)
List implements the storage.Backend interface.
func (*Backend) ListByOwner ¶
func (b *Backend) ListByOwner(_ context.Context, id *pbresource.ID) ([]*pbresource.Resource, error)
ListByOwner implements the storage.Backend interface.
func (*Backend) Read ¶
func (b *Backend) Read(_ context.Context, _ storage.ReadConsistency, id *pbresource.ID) (*pbresource.Resource, error)
Read implements the storage.Backend interface.
func (*Backend) Run ¶
Run until the given context is canceled. This method blocks, so should be called in a goroutine.
func (*Backend) WatchList ¶
func (b *Backend) WatchList(_ context.Context, resType storage.UnversionedType, tenancy *pbresource.Tenancy, namePrefix string) (storage.Watch, error)
WatchList implements the storage.Backend interface.
func (*Backend) WriteCAS ¶
func (b *Backend) WriteCAS(_ context.Context, res *pbresource.Resource) (*pbresource.Resource, error)
WriteCAS implements the storage.Backend interface.
type Restoration ¶
type Restoration struct {
// contains filtered or unexported fields
}
Restoration is a handle that can be used to restore a snapshot.
func (*Restoration) Abort ¶
func (r *Restoration) Abort()
Abort the restoration. It's safe to always call this in a defer statement because aborting a committed restoration is a no-op.
func (*Restoration) Apply ¶
func (r *Restoration) Apply(res *pbresource.Resource) error
Apply the given resource to the store.
func (*Restoration) Commit ¶
func (r *Restoration) Commit()
Commit the restoration. Replaces the in-memory database wholesale and closes any watches.
type Snapshot ¶
type Snapshot struct {
// contains filtered or unexported fields
}
Snapshot is a point-in-time snapshot of a store.
func (*Snapshot) Next ¶
func (s *Snapshot) Next() *pbresource.Resource
Next returns the next resource in the snapshot. nil will be returned when the end of the snapshot has been reached.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements an in-memory resource database using go-memdb.
It can be used as a storage backend directly via the Backend type in this package, but also handles reads in our Raft backend, and can be used as a local cache when storing data in external systems (e.g. RDBMS, K/V stores).
func (*Store) DeleteCAS ¶
func (s *Store) DeleteCAS(id *pbresource.ID, vsn string) error
DeleteCAS performs an atomic Compare-And-Swap (CAS) deletion of a resource.
For more information, see the storage.Backend documentation.
func (*Store) List ¶
func (s *Store) List(typ storage.UnversionedType, ten *pbresource.Tenancy, namePrefix string) ([]*pbresource.Resource, error)
List resources of the given type, tenancy, and optionally matching the given name prefix.
For more information, see the storage.Backend documentation.
func (*Store) ListByOwner ¶
func (s *Store) ListByOwner(id *pbresource.ID) ([]*pbresource.Resource, error)
ListByOwner returns resources owned by the resource with the given ID.
For more information, see the storage.Backend documentation.
func (*Store) Read ¶
func (s *Store) Read(id *pbresource.ID) (*pbresource.Resource, error)
Read a resource using its ID.
For more information, see the storage.Backend documentation.
func (*Store) Restore ¶
func (s *Store) Restore() (*Restoration, error)
Restore starts the process of restoring a snapshot.
Callers *must* call Abort or Commit when done, to free resources.
func (*Store) Run ¶
Run until the given context is canceled. This method blocks, so should be called in a goroutine.
func (*Store) Snapshot ¶
Snapshot obtains a point-in-time snapshot of the store that can later be persisted and restored later.
func (*Store) WatchList ¶
func (s *Store) WatchList(typ storage.UnversionedType, ten *pbresource.Tenancy, namePrefix string) (*Watch, error)
WatchList watches resources of the given type, tenancy, and optionally matching the given name prefix.
For more information, see the storage.Backend documentation.
type Watch ¶
type Watch struct {
// contains filtered or unexported fields
}
Watch implements the storage.Watch interface using a stream.Subscription.
func (*Watch) Next ¶
func (w *Watch) Next(ctx context.Context) (*pbresource.WatchEvent, error)
Next returns the next WatchEvent, blocking until one is available.