databroker: add support for putting multiple records (#3291)

* databroker: add support for putting multiple records

* add OptimumPutRequestsFromRecords function

* replace GetAll with SyncLatest

* fix stream when there are no records
This commit is contained in:
Caleb Doxsey 2022-04-26 22:41:38 +00:00 committed by GitHub
parent 343fa43ed4
commit f73c5c615f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 790 additions and 660 deletions

View file

@ -13,27 +13,22 @@ import (
type mockBackend struct {
Backend
put func(ctx context.Context, record *databroker.Record) (uint64, error)
get func(ctx context.Context, recordType, id string) (*databroker.Record, error)
getAll func(ctx context.Context) ([]*databroker.Record, *databroker.Versions, error)
put func(ctx context.Context, records []*databroker.Record) (uint64, error)
get func(ctx context.Context, recordType, id string) (*databroker.Record, error)
}
func (m *mockBackend) Close() error {
return nil
}
func (m *mockBackend) Put(ctx context.Context, record *databroker.Record) (uint64, error) {
return m.put(ctx, record)
func (m *mockBackend) Put(ctx context.Context, records []*databroker.Record) (uint64, error) {
return m.put(ctx, records)
}
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, *databroker.Versions, error) {
return m.getAll(ctx)
}
func TestMatchAny(t *testing.T) {
u := &user.User{Id: "id", Name: "name", Email: "email"}
data := protoutil.NewAny(u)