mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-18 03:27:16 +02:00
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:
parent
343fa43ed4
commit
f73c5c615f
28 changed files with 790 additions and 660 deletions
|
@ -58,19 +58,19 @@ func TestServer_Get(t *testing.T) {
|
|||
s.Id = "1"
|
||||
any := protoutil.NewAny(s)
|
||||
_, err := srv.Put(context.Background(), &databroker.PutRequest{
|
||||
Record: &databroker.Record{
|
||||
Records: []*databroker.Record{{
|
||||
Type: any.TypeUrl,
|
||||
Id: s.Id,
|
||||
Data: any,
|
||||
},
|
||||
}},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
_, err = srv.Put(context.Background(), &databroker.PutRequest{
|
||||
Record: &databroker.Record{
|
||||
Records: []*databroker.Record{{
|
||||
Type: any.TypeUrl,
|
||||
Id: s.Id,
|
||||
DeletedAt: timestamppb.Now(),
|
||||
},
|
||||
}},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
_, err = srv.Get(context.Background(), &databroker.GetRequest{
|
||||
|
@ -90,11 +90,11 @@ func TestServer_Options(t *testing.T) {
|
|||
s.Id = "1"
|
||||
any := protoutil.NewAny(s)
|
||||
_, err := srv.Put(context.Background(), &databroker.PutRequest{
|
||||
Record: &databroker.Record{
|
||||
Records: []*databroker.Record{{
|
||||
Type: any.TypeUrl,
|
||||
Id: s.Id,
|
||||
Data: any,
|
||||
},
|
||||
}},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
_, err = srv.SetOptions(context.Background(), &databroker.SetOptionsRequest{
|
||||
|
@ -139,11 +139,11 @@ func TestServer_Query(t *testing.T) {
|
|||
s.Id = "1"
|
||||
any := protoutil.NewAny(s)
|
||||
_, err := srv.Put(context.Background(), &databroker.PutRequest{
|
||||
Record: &databroker.Record{
|
||||
Records: []*databroker.Record{{
|
||||
Type: any.TypeUrl,
|
||||
Id: s.Id,
|
||||
Data: any,
|
||||
},
|
||||
}},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
_, err = srv.Query(context.Background(), &databroker.QueryRequest{
|
||||
|
@ -160,11 +160,11 @@ func TestServer_Sync(t *testing.T) {
|
|||
s.Id = "1"
|
||||
any := protoutil.NewAny(s)
|
||||
_, err := srv.Put(context.Background(), &databroker.PutRequest{
|
||||
Record: &databroker.Record{
|
||||
Records: []*databroker.Record{{
|
||||
Type: any.TypeUrl,
|
||||
Id: s.Id,
|
||||
Data: any,
|
||||
},
|
||||
}},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
@ -216,11 +216,11 @@ func TestServer_Sync(t *testing.T) {
|
|||
}
|
||||
|
||||
_, err = srv.Put(context.Background(), &databroker.PutRequest{
|
||||
Record: &databroker.Record{
|
||||
Records: []*databroker.Record{{
|
||||
Type: any.TypeUrl,
|
||||
Id: s.Id,
|
||||
Data: any,
|
||||
},
|
||||
}},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
@ -244,11 +244,11 @@ func TestServerInvalidStorage(t *testing.T) {
|
|||
s.Id = "1"
|
||||
any := protoutil.NewAny(s)
|
||||
_, err := srv.Put(context.Background(), &databroker.PutRequest{
|
||||
Record: &databroker.Record{
|
||||
Records: []*databroker.Record{{
|
||||
Type: any.TypeUrl,
|
||||
Id: s.Id,
|
||||
Data: any,
|
||||
},
|
||||
}},
|
||||
})
|
||||
_ = assert.Error(t, err) && assert.Contains(t, err.Error(), "unsupported storage type")
|
||||
}
|
||||
|
@ -265,11 +265,11 @@ func TestServerRedis(t *testing.T) {
|
|||
s.Id = "1"
|
||||
any := protoutil.NewAny(s)
|
||||
_, err := srv.Put(context.Background(), &databroker.PutRequest{
|
||||
Record: &databroker.Record{
|
||||
Records: []*databroker.Record{{
|
||||
Type: any.TypeUrl,
|
||||
Id: s.Id,
|
||||
Data: any,
|
||||
},
|
||||
}},
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue