mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 20:38:00 +00:00
1d84635836
# Which Problems Are Solved To improve performance a new table and method is implemented on eventstore. The goal of this table is to index searchable fields on command side to use it on command and query side. The table allows to store one primitive value (numeric, text) per row. The eventstore framework is extended by the `Search`-method which allows to search for objects. The `Command`-interface is extended by the `SearchOperations()`-method which does manipulate the the `search`-table. # How the Problems Are Solved This PR adds the capability of improving performance for command and query side by using the `Search`-method of the eventstore instead of using one of the `Filter`-methods. # Open Tasks - [x] Add feature flag - [x] Unit tests - [ ] ~~Benchmarks if needed~~ - [x] Ensure no behavior change - [x] Add setup step to fill table with current data - [x] Add projection which ensures data added between setup and start of the new version are also added to the table # Additional Changes The `Search`-method is currently used by `ProjectGrant`-command side. # Additional Context - Closes https://github.com/zitadel/zitadel/issues/8094
69 lines
1.5 KiB
Go
69 lines
1.5 KiB
Go
package eventstore
|
|
|
|
import (
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
)
|
|
|
|
var _ eventstore.Command = (*mockCommand)(nil)
|
|
|
|
type mockCommand struct {
|
|
aggregate *eventstore.Aggregate
|
|
payload any
|
|
constraints []*eventstore.UniqueConstraint
|
|
}
|
|
|
|
// Aggregate implements [eventstore.Command]
|
|
func (m *mockCommand) Aggregate() *eventstore.Aggregate {
|
|
return m.aggregate
|
|
}
|
|
|
|
// Creator implements [eventstore.Command]
|
|
func (m *mockCommand) Creator() string {
|
|
return "creator"
|
|
}
|
|
|
|
// Revision implements [eventstore.Command]
|
|
func (m *mockCommand) Revision() uint16 {
|
|
return 1
|
|
}
|
|
|
|
// Type implements [eventstore.Command]
|
|
func (m *mockCommand) Type() eventstore.EventType {
|
|
return "event.type"
|
|
}
|
|
|
|
// Payload implements [eventstore.Command]
|
|
func (m *mockCommand) Payload() any {
|
|
return m.payload
|
|
}
|
|
|
|
// UniqueConstraints implements [eventstore.Command]
|
|
func (m *mockCommand) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return m.constraints
|
|
}
|
|
|
|
func (e *mockCommand) Fields() []*eventstore.FieldOperation {
|
|
return nil
|
|
}
|
|
|
|
func mockEvent(aggregate *eventstore.Aggregate, sequence uint64, payload Payload) eventstore.Event {
|
|
return &event{
|
|
aggregate: aggregate,
|
|
creator: "creator",
|
|
revision: 1,
|
|
typ: "event.type",
|
|
sequence: sequence,
|
|
payload: payload,
|
|
}
|
|
}
|
|
|
|
func mockAggregate(id string) *eventstore.Aggregate {
|
|
return &eventstore.Aggregate{
|
|
ID: id,
|
|
Type: "type",
|
|
ResourceOwner: "ro",
|
|
InstanceID: "instance",
|
|
Version: "v1",
|
|
}
|
|
}
|