mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-02 00:10:45 +02:00
databroker: refactor databroker to sync all changes (#1879)
* refactor backend, implement encrypted store * refactor in-memory store * wip * wip * wip * add syncer test * fix redis expiry * fix linting issues * fix test by skipping non-config records * fix backoff import * fix init issues * fix query * wait for initial sync before starting directory sync * add type to SyncLatest * add more log messages, fix deadlock in in-memory store, always return server version from SyncLatest * update sync types and tests * add redis tests * skip macos in github actions * add comments to proto * split getBackend into separate methods * handle errors in initVersion * return different error for not found vs other errors in get * use exponential backoff for redis transaction retry * rename raw to result * use context instead of close channel * store type urls as constants in databroker * use timestampb instead of ptypes * fix group merging not waiting * change locked names * update GetAll to return latest record version * add method to grpcutil to get the type url for a protobuf type
This commit is contained in:
parent
b1871b0f2e
commit
5d60cff21e
66 changed files with 2762 additions and 2871 deletions
|
@ -3,7 +3,6 @@ package storage
|
|||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/protobuf/types/known/anypb"
|
||||
|
@ -13,50 +12,29 @@ import (
|
|||
)
|
||||
|
||||
type mockBackend struct {
|
||||
put func(ctx context.Context, id string, data *anypb.Any) error
|
||||
get func(ctx context.Context, id string) (*databroker.Record, error)
|
||||
getAll func(ctx context.Context) ([]*databroker.Record, error)
|
||||
list func(ctx context.Context, sinceVersion string) ([]*databroker.Record, error)
|
||||
delete func(ctx context.Context, id string) error
|
||||
clearDeleted func(ctx context.Context, cutoff time.Time)
|
||||
query func(ctx context.Context, query string, offset, limit int) ([]*databroker.Record, int, error)
|
||||
watch func(ctx context.Context) <-chan struct{}
|
||||
put func(ctx context.Context, record *databroker.Record) error
|
||||
get func(ctx context.Context, recordType, id string) (*databroker.Record, error)
|
||||
getAll func(ctx context.Context) ([]*databroker.Record, uint64, error)
|
||||
}
|
||||
|
||||
func (m *mockBackend) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *mockBackend) Put(ctx context.Context, id string, data *anypb.Any) error {
|
||||
return m.put(ctx, id, data)
|
||||
func (m *mockBackend) Put(ctx context.Context, record *databroker.Record) error {
|
||||
return m.put(ctx, record)
|
||||
}
|
||||
|
||||
func (m *mockBackend) Get(ctx context.Context, id string) (*databroker.Record, error) {
|
||||
return m.get(ctx, id)
|
||||
func (m *mockBackend) Get(ctx context.Context, recordType, id string) (*databroker.Record, error) {
|
||||
return m.get(ctx, recordType, id)
|
||||
}
|
||||
|
||||
func (m *mockBackend) GetAll(ctx context.Context) ([]*databroker.Record, error) {
|
||||
func (m *mockBackend) GetAll(ctx context.Context) ([]*databroker.Record, uint64, error) {
|
||||
return m.getAll(ctx)
|
||||
}
|
||||
|
||||
func (m *mockBackend) List(ctx context.Context, sinceVersion string) ([]*databroker.Record, error) {
|
||||
return m.list(ctx, sinceVersion)
|
||||
}
|
||||
|
||||
func (m *mockBackend) Delete(ctx context.Context, id string) error {
|
||||
return m.delete(ctx, id)
|
||||
}
|
||||
|
||||
func (m *mockBackend) ClearDeleted(ctx context.Context, cutoff time.Time) {
|
||||
m.clearDeleted(ctx, cutoff)
|
||||
}
|
||||
|
||||
func (m *mockBackend) Query(ctx context.Context, query string, offset, limit int) ([]*databroker.Record, int, error) {
|
||||
return m.query(ctx, query, offset, limit)
|
||||
}
|
||||
|
||||
func (m *mockBackend) Watch(ctx context.Context) <-chan struct{} {
|
||||
return m.watch(ctx)
|
||||
func (m *mockBackend) Sync(ctx context.Context, version uint64) (RecordStream, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func TestMatchAny(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue