mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-31 09:57:17 +02:00
* pkg: add storage package Which contains storage.Backend interface to initial support for multiple backend storage. * pkg/storage: add inmemory storage * internal/databroker: use storage.Backend interface Instead of implementing multiple databroker server implementation for each kind of storage backend, we use only one databroker server implementation, which is supported multiple storage backends, which satisfy storage.Backend interface.
31 lines
872 B
Go
31 lines
872 B
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"google.golang.org/protobuf/types/known/anypb"
|
|
|
|
"github.com/pomerium/pomerium/pkg/grpc/databroker"
|
|
)
|
|
|
|
// Backend is the interface required for a storage backend.
|
|
type Backend interface {
|
|
// Put is used to insert or update a record.
|
|
Put(ctx context.Context, id string, data *anypb.Any) error
|
|
|
|
// Get is used to retrieve a record.
|
|
Get(ctx context.Context, id string) *databroker.Record
|
|
|
|
// GetAll is used to retrieve all the records.
|
|
GetAll(ctx context.Context) []*databroker.Record
|
|
|
|
// List is used to retrieve all the records since a version.
|
|
List(ctx context.Context, sinceVersion string) []*databroker.Record
|
|
|
|
// Delete is used to mark a record as deleted.
|
|
Delete(ctx context.Context, id string) error
|
|
|
|
// ClearDeleted is used clear marked delete records.
|
|
ClearDeleted(ctx context.Context, cutoff time.Time)
|
|
}
|