mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-02 20:32:19 +00:00
feat: instance remove (#4345)
* feat(instance): add remove instance event with projections cleanup * fix(instance): corrected used id to clean up projections * fix merge * fix: correct unit test projection names * fix: current sequence of lists and query for ensuring keypair based projections Co-authored-by: Livio Spring <[email protected]> Co-authored-by: Fabi <[email protected]>
This commit is contained in:
co-authored by
Livio Spring
Fabi
parent
6e89b7d0a1
commit
c2a5b785fb
@@ -66,6 +66,10 @@ func (p *instanceProjection) reducers() []handler.AggregateReducer {
|
||||
Event: instance.InstanceChangedEventType,
|
||||
Reduce: p.reduceInstanceChanged,
|
||||
},
|
||||
{
|
||||
Event: instance.InstanceRemovedEventType,
|
||||
Reduce: reduceInstanceRemovedHelper(InstanceColumnID),
|
||||
},
|
||||
{
|
||||
Event: instance.DefaultOrgSetEventType,
|
||||
Reduce: p.reduceDefaultOrgSet,
|
||||
@@ -104,6 +108,21 @@ func (p *instanceProjection) reduceInstanceAdded(event eventstore.Event) (*handl
|
||||
), nil
|
||||
}
|
||||
|
||||
func reduceInstanceRemovedHelper(instanceIDCol string) func(event eventstore.Event) (*handler.Statement, error) {
|
||||
return func(event eventstore.Event) (*handler.Statement, error) {
|
||||
e, ok := event.(*instance.InstanceRemovedEvent)
|
||||
if !ok {
|
||||
return nil, errors.ThrowInvalidArgumentf(nil, "HANDL-22nlS", "reduce.wrong.event.type %s", instance.InstanceRemovedEventType)
|
||||
}
|
||||
return crdb.NewDeleteStatement(
|
||||
e,
|
||||
[]handler.Condition{
|
||||
handler.NewCond(instanceIDCol, e.Aggregate().ID),
|
||||
},
|
||||
), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (p *instanceProjection) reduceInstanceChanged(event eventstore.Event) (*handler.Statement, error) {
|
||||
e, ok := event.(*instance.InstanceChangedEvent)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user