append events without return value

This commit is contained in:
adlerhurst 2020-11-25 14:12:44 +01:00
parent f8028f07d0
commit f6cdcee77a
27 changed files with 73 additions and 78 deletions

View File

@ -142,7 +142,7 @@ type reducer interface {
// it only appends the newly added events // it only appends the newly added events
Reduce() error Reduce() error
//AppendEvents appends the passed events to an internal list of events //AppendEvents appends the passed events to an internal list of events
AppendEvents(...EventReader) error AppendEvents(...EventReader)
} }
//FilterToReducer filters the events based on the search query, appends all events to the reducer and calls it's reduce function //FilterToReducer filters the events based on the search query, appends all events to the reducer and calls it's reduce function
@ -151,9 +151,8 @@ func (es *Eventstore) FilterToReducer(ctx context.Context, searchQuery *SearchQu
if err != nil { if err != nil {
return err return err
} }
if err = r.AppendEvents(events...); err != nil {
return err r.AppendEvents(events...)
}
return r.Reduce() return r.Reduce()
} }
@ -180,9 +179,7 @@ func (es *Eventstore) FilterToQueryReducer(ctx context.Context, r queryReducer)
if err != nil { if err != nil {
return err return err
} }
if err = r.AppendEvents(events...); err != nil { r.AppendEvents(events...)
return err
}
return r.Reduce() return r.Reduce()
} }

View File

@ -1,5 +1,7 @@
package eventstore package eventstore
import "time"
func NewWriteModel() *WriteModel { func NewWriteModel() *WriteModel {
return &WriteModel{ return &WriteModel{
Events: []EventReader{}, Events: []EventReader{},
@ -14,6 +16,7 @@ type WriteModel struct {
ProcessedSequence uint64 `json:"-"` ProcessedSequence uint64 `json:"-"`
Events []EventReader `json:"-"` Events []EventReader `json:"-"`
ResourceOwner string `json:"-"` ResourceOwner string `json:"-"`
ChangeDate time.Time `json:"-"`
} }
//AppendEvents adds all the events to the read model. //AppendEvents adds all the events to the read model.
@ -38,6 +41,7 @@ func (wm *WriteModel) Reduce() error {
} }
wm.ProcessedSequence = wm.Events[len(wm.Events)-1].Sequence() wm.ProcessedSequence = wm.Events[len(wm.Events)-1].Sequence()
wm.ChangeDate = wm.Events[len(wm.Events)-1].CreationDate()
// all events processed and not needed anymore // all events processed and not needed anymore
wm.Events = nil wm.Events = nil

View File

@ -60,11 +60,13 @@ func (r *Repository) ChangeIAMMember(ctx context.Context, member *iam_model.IAMM
iam := iam_repo.AggregateFromWriteModel(&existingMember.WriteModel.WriteModel). iam := iam_repo.AggregateFromWriteModel(&existingMember.WriteModel.WriteModel).
PushMemberChangedFromExisting(ctx, existingMember, member.Roles...) PushMemberChangedFromExisting(ctx, existingMember, member.Roles...)
_, err = r.eventstore.PushAggregates(ctx, iam) events, err := r.eventstore.PushAggregates(ctx, iam)
if err != nil { if err != nil {
return nil, err return nil, err
} }
existingMember.AppendEvents(events...)
updatedMember, err := r.MemberByID(ctx, member.AggregateID, member.UserID) updatedMember, err := r.MemberByID(ctx, member.AggregateID, member.UserID)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -37,10 +37,8 @@ func (r *Repository) iamByID(ctx context.Context, id string) (_ *iam_repo.ReadMo
ctx, span := tracing.NewSpan(ctx) ctx, span := tracing.NewSpan(ctx)
defer func() { span.EndWithError(err) }() defer func() { span.EndWithError(err) }()
query := eventstore.NewSearchQueryFactory(eventstore.ColumnsEvent, iam_repo.AggregateType).AggregateIDs(id) readModel := iam_repo.NewReadModel(id)
err = r.eventstore.FilterToQueryReducer(ctx, readModel)
readModel := new(iam_repo.ReadModel)
err = r.eventstore.FilterToReducer(ctx, query, readModel)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -52,7 +50,7 @@ func (r *Repository) memberWriteModelByID(ctx context.Context, iamID, userID str
ctx, span := tracing.NewSpan(ctx) ctx, span := tracing.NewSpan(ctx)
defer func() { span.EndWithError(err) }() defer func() { span.EndWithError(err) }()
writeModel := iam_repo.PrepareMemberWriteModel(iamID, userID) writeModel := iam_repo.NewMemberReadModel(iamID, userID)
err = r.eventstore.FilterToQueryReducer(ctx, writeModel) err = r.eventstore.FilterToQueryReducer(ctx, writeModel)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -18,8 +18,8 @@ const (
type Aggregate struct { type Aggregate struct {
eventstore.Aggregate eventstore.Aggregate
SetUpStarted Step // SetUpStarted Step
SetUpDone Step // SetUpDone Step
} }
func NewAggregate( func NewAggregate(
@ -47,9 +47,15 @@ func AggregateFromWriteModel(wm *eventstore.WriteModel) *Aggregate {
func AggregateFromReadModel(rm *ReadModel) *Aggregate { func AggregateFromReadModel(rm *ReadModel) *Aggregate {
return &Aggregate{ return &Aggregate{
Aggregate: *eventstore.NewAggregate(rm.AggregateID, AggregateType, rm.ResourceOwner, AggregateVersion, rm.ProcessedSequence), Aggregate: *eventstore.NewAggregate(
SetUpDone: rm.SetUpDone, rm.AggregateID,
SetUpStarted: rm.SetUpStarted, AggregateType,
rm.ResourceOwner,
AggregateVersion,
rm.ProcessedSequence,
),
// SetUpDone: rm.SetUpDone,
// SetUpStarted: rm.SetUpStarted,
} }
} }

View File

@ -17,7 +17,7 @@ type MemberReadModel struct {
member.ReadModel member.ReadModel
} }
func (rm *MemberReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *MemberReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *MemberAddedEvent: case *MemberAddedEvent:
@ -28,20 +28,19 @@ func (rm *MemberReadModel) AppendEvents(events ...eventstore.EventReader) (err e
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type MemberWriteModel struct { type MemberWriteModel struct {
member.WriteModel member.WriteModel
} }
func PrepareMemberWriteModel(iamID, userID string) *MemberWriteModel { func NewMemberReadModel(iamID, userID string) *MemberWriteModel {
return &MemberWriteModel{ return &MemberWriteModel{
WriteModel: *member.PrepareWriteModel(userID, AggregateType, iamID), WriteModel: *member.NewWriteModel(userID, AggregateType, iamID),
} }
} }
func (wm *MemberWriteModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (wm *MemberWriteModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *MemberAddedEvent: case *MemberAddedEvent:
@ -54,20 +53,12 @@ func (wm *MemberWriteModel) AppendEvents(events ...eventstore.EventReader) (err
wm.WriteModel.AppendEvents(e) wm.WriteModel.AppendEvents(e)
} }
} }
return nil
} }
type MemberAddedEvent struct { type MemberAddedEvent struct {
member.AddedEvent member.AddedEvent
} }
type MemberChangedEvent struct {
member.ChangedEvent
}
type MemberRemovedEvent struct {
member.RemovedEvent
}
func NewMemberAddedEvent( func NewMemberAddedEvent(
ctx context.Context, ctx context.Context,
userID string, userID string,
@ -86,6 +77,10 @@ func NewMemberAddedEvent(
} }
} }
type MemberChangedEvent struct {
member.ChangedEvent
}
func MemberChangedEventFromExisting( func MemberChangedEventFromExisting(
ctx context.Context, ctx context.Context,
current *MemberWriteModel, current *MemberWriteModel,
@ -127,6 +122,10 @@ func NewMemberChangedEvent(
} }
} }
type MemberRemovedEvent struct {
member.RemovedEvent
}
func NewMemberRemovedEvent( func NewMemberRemovedEvent(
ctx context.Context, ctx context.Context,
userID string, userID string,

View File

@ -10,7 +10,7 @@ type MembersReadModel struct {
members.ReadModel members.ReadModel
} }
func (rm *MembersReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *MembersReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *MemberAddedEvent: case *MemberAddedEvent:
@ -23,5 +23,4 @@ func (rm *MembersReadModel) AppendEvents(events ...eventstore.EventReader) (err
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }

View File

@ -12,7 +12,7 @@ var (
type LabelPolicyReadModel struct{ policy.LabelPolicyReadModel } type LabelPolicyReadModel struct{ policy.LabelPolicyReadModel }
func (rm *LabelPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *LabelPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *LabelPolicyAddedEvent: case *LabelPolicyAddedEvent:
@ -23,7 +23,6 @@ func (rm *LabelPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type LabelPolicyAddedEvent struct { type LabelPolicyAddedEvent struct {

View File

@ -12,7 +12,7 @@ var (
type LoginPolicyReadModel struct{ policy.LoginPolicyReadModel } type LoginPolicyReadModel struct{ policy.LoginPolicyReadModel }
func (rm *LoginPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *LoginPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *LoginPolicyAddedEvent: case *LoginPolicyAddedEvent:
@ -23,7 +23,6 @@ func (rm *LoginPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type LoginPolicyAddedEvent struct { type LoginPolicyAddedEvent struct {

View File

@ -11,7 +11,7 @@ var (
type OrgIAMPolicyReadModel struct{ policy.OrgIAMPolicyReadModel } type OrgIAMPolicyReadModel struct{ policy.OrgIAMPolicyReadModel }
func (rm *OrgIAMPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *OrgIAMPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *OrgIAMPolicyAddedEvent: case *OrgIAMPolicyAddedEvent:
@ -20,7 +20,6 @@ func (rm *OrgIAMPolicyReadModel) AppendEvents(events ...eventstore.EventReader)
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type OrgIAMPolicyAddedEvent struct { type OrgIAMPolicyAddedEvent struct {

View File

@ -14,7 +14,7 @@ type PasswordAgePolicyReadModel struct {
policy.PasswordAgePolicyReadModel policy.PasswordAgePolicyReadModel
} }
func (rm *PasswordAgePolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *PasswordAgePolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *PasswordAgePolicyAddedEvent: case *PasswordAgePolicyAddedEvent:
@ -25,7 +25,6 @@ func (rm *PasswordAgePolicyReadModel) AppendEvents(events ...eventstore.EventRea
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type PasswordAgePolicyAddedEvent struct { type PasswordAgePolicyAddedEvent struct {

View File

@ -14,7 +14,7 @@ type PasswordComplexityPolicyReadModel struct {
policy.PasswordComplexityPolicyReadModel policy.PasswordComplexityPolicyReadModel
} }
func (rm *PasswordComplexityPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *PasswordComplexityPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *PasswordComplexityPolicyAddedEvent: case *PasswordComplexityPolicyAddedEvent:
@ -25,7 +25,6 @@ func (rm *PasswordComplexityPolicyReadModel) AppendEvents(events ...eventstore.E
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type PasswordComplexityPolicyAddedEvent struct { type PasswordComplexityPolicyAddedEvent struct {

View File

@ -14,7 +14,7 @@ type PasswordLockoutPolicyReadModel struct {
policy.PasswordLockoutPolicyReadModel policy.PasswordLockoutPolicyReadModel
} }
func (rm *PasswordLockoutPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *PasswordLockoutPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *PasswordLockoutPolicyAddedEvent: case *PasswordLockoutPolicyAddedEvent:
@ -25,7 +25,6 @@ func (rm *PasswordLockoutPolicyReadModel) AppendEvents(events ...eventstore.Even
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type PasswordLockoutPolicyAddedEvent struct { type PasswordLockoutPolicyAddedEvent struct {

View File

@ -25,7 +25,15 @@ type ReadModel struct {
DefaultPasswordLockoutPolicy PasswordLockoutPolicyReadModel DefaultPasswordLockoutPolicy PasswordLockoutPolicyReadModel
} }
func (rm *ReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func NewReadModel(id string) *ReadModel {
return &ReadModel{
ReadModel: eventstore.ReadModel{
AggregateID: id,
},
}
}
func (rm *ReadModel) AppendEvents(events ...eventstore.EventReader) {
rm.ReadModel.AppendEvents(events...) rm.ReadModel.AppendEvents(events...)
for _, event := range events { for _, event := range events {
switch event.(type) { switch event.(type) {
@ -45,7 +53,6 @@ func (rm *ReadModel) AppendEvents(events ...eventstore.EventReader) (err error)
rm.DefaultPasswordLockoutPolicy.AppendEvents(event) rm.DefaultPasswordLockoutPolicy.AppendEvents(event)
} }
} }
return err
} }
func (rm *ReadModel) Reduce() (err error) { func (rm *ReadModel) Reduce() (err error) {
@ -87,3 +94,7 @@ func (rm *ReadModel) AppendAndReduce(events ...eventstore.EventReader) error {
} }
return rm.Reduce() return rm.Reduce()
} }
func (rm *ReadModel) Query() *eventstore.SearchQueryFactory {
return eventstore.NewSearchQueryFactory(eventstore.ColumnsEvent, AggregateType).AggregateIDs(rm.AggregateID)
}

View File

@ -27,10 +27,8 @@ type ConfigReadModel struct {
OIDCConfig *oidc.ConfigReadModel OIDCConfig *oidc.ConfigReadModel
} }
func (rm *ConfigReadModel) AppendEvents(events ...eventstore.EventReader) error { func (rm *ConfigReadModel) AppendEvents(events ...eventstore.EventReader) {
rm.ReadModel.AppendEvents(events...) rm.ReadModel.AppendEvents(events...)
return nil
} }
func (rm *ConfigReadModel) Reduce() error { func (rm *ConfigReadModel) Reduce() error {

View File

@ -18,8 +18,8 @@ type ConfigReadModel struct {
UsernameMapping MappingField UsernameMapping MappingField
} }
func (rm *ConfigReadModel) AppendEvents(events ...eventstore.EventReader) error { func (rm *ConfigReadModel) AppendEvents(events ...eventstore.EventReader) {
return nil rm.ReadModel.AppendEvents(events...)
} }
func (rm *ConfigReadModel) Reduce() error { func (rm *ConfigReadModel) Reduce() error {

View File

@ -37,10 +37,7 @@ func ChangeEventFromExisting(
roles ...string, roles ...string,
) (*ChangedEvent, error) { ) (*ChangedEvent, error) {
change := &ChangedEvent{ change := NewChangedEvent(base, current.userID)
BaseEvent: *base,
UserID: current.UserID,
}
sort.Strings(current.Roles) sort.Strings(current.Roles)
sort.Strings(roles) sort.Strings(roles)

View File

@ -17,7 +17,7 @@ type WriteModel struct {
aggregateID string aggregateID string
} }
func PrepareWriteModel( func NewWriteModel(
userID string, userID string,
aggregateType eventstore.AggregateType, aggregateType eventstore.AggregateType,
aggregateID string, aggregateID string,

View File

@ -27,7 +27,7 @@ func (rm *ReadModel) MemberByUserID(id string) (idx int, member *member.ReadMode
return -1, nil return -1, nil
} }
func (rm *ReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *ReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *member.AddedEvent: case *member.AddedEvent:
@ -40,14 +40,13 @@ func (rm *ReadModel) AppendEvents(events ...eventstore.EventReader) (err error)
case *member.RemovedEvent: case *member.RemovedEvent:
idx, _ := rm.MemberByUserID(e.UserID) idx, _ := rm.MemberByUserID(e.UserID)
if idx < 0 { if idx < 0 {
return nil continue
} }
copy(rm.Members[idx:], rm.Members[idx+1:]) copy(rm.Members[idx:], rm.Members[idx+1:])
rm.Members[len(rm.Members)-1] = nil rm.Members[len(rm.Members)-1] = nil
rm.Members = rm.Members[:len(rm.Members)-1] rm.Members = rm.Members[:len(rm.Members)-1]
} }
} }
return err
} }
func (rm *ReadModel) Reduce() (err error) { func (rm *ReadModel) Reduce() (err error) {

View File

@ -35,7 +35,7 @@ type MembersReadModel struct {
members.ReadModel members.ReadModel
} }
func (rm *MembersReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *MembersReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *MemberAddedEvent: case *MemberAddedEvent:
@ -46,12 +46,11 @@ func (rm *MembersReadModel) AppendEvents(events ...eventstore.EventReader) (err
rm.ReadModel.AppendEvents(&e.RemovedEvent) rm.ReadModel.AppendEvents(&e.RemovedEvent)
} }
} }
return nil
} }
type MemberReadModel member.ReadModel type MemberReadModel member.ReadModel
func (rm *MemberReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *MemberReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *MemberAddedEvent: case *MemberAddedEvent:
@ -60,7 +59,6 @@ func (rm *MemberReadModel) AppendEvents(events ...eventstore.EventReader) (err e
rm.ReadModel.AppendEvents(&e.ChangedEvent) rm.ReadModel.AppendEvents(&e.ChangedEvent)
} }
} }
return nil
} }
type MemberAddedEvent struct { type MemberAddedEvent struct {

View File

@ -12,7 +12,7 @@ var (
type LabelPolicyReadModel struct{ policy.LabelPolicyReadModel } type LabelPolicyReadModel struct{ policy.LabelPolicyReadModel }
func (rm *LabelPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *LabelPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *LabelPolicyAddedEvent: case *LabelPolicyAddedEvent:
@ -23,7 +23,6 @@ func (rm *LabelPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type LabelPolicyAddedEvent struct { type LabelPolicyAddedEvent struct {

View File

@ -12,7 +12,7 @@ var (
type LoginPolicyReadModel struct{ policy.LoginPolicyReadModel } type LoginPolicyReadModel struct{ policy.LoginPolicyReadModel }
func (rm *LoginPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *LoginPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *LoginPolicyAddedEvent: case *LoginPolicyAddedEvent:
@ -23,7 +23,6 @@ func (rm *LoginPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type LoginPolicyAddedEvent struct { type LoginPolicyAddedEvent struct {

View File

@ -11,7 +11,7 @@ var (
type OrgIAMPolicyReadModel struct{ policy.OrgIAMPolicyReadModel } type OrgIAMPolicyReadModel struct{ policy.OrgIAMPolicyReadModel }
func (rm *OrgIAMPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *OrgIAMPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *OrgIAMPolicyAddedEvent: case *OrgIAMPolicyAddedEvent:
@ -20,7 +20,6 @@ func (rm *OrgIAMPolicyReadModel) AppendEvents(events ...eventstore.EventReader)
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type OrgIAMPolicyAddedEvent struct { type OrgIAMPolicyAddedEvent struct {

View File

@ -14,7 +14,7 @@ type PasswordAgePolicyReadModel struct {
policy.PasswordAgePolicyReadModel policy.PasswordAgePolicyReadModel
} }
func (rm *PasswordAgePolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *PasswordAgePolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *PasswordAgePolicyAddedEvent: case *PasswordAgePolicyAddedEvent:
@ -25,7 +25,6 @@ func (rm *PasswordAgePolicyReadModel) AppendEvents(events ...eventstore.EventRea
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type PasswordAgePolicyAddedEvent struct { type PasswordAgePolicyAddedEvent struct {

View File

@ -14,7 +14,7 @@ type PasswordComplexityPolicyReadModel struct {
policy.PasswordComplexityPolicyReadModel policy.PasswordComplexityPolicyReadModel
} }
func (rm *PasswordComplexityPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *PasswordComplexityPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *PasswordComplexityPolicyAddedEvent: case *PasswordComplexityPolicyAddedEvent:
@ -25,7 +25,6 @@ func (rm *PasswordComplexityPolicyReadModel) AppendEvents(events ...eventstore.E
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type PasswordComplexityPolicyAddedEvent struct { type PasswordComplexityPolicyAddedEvent struct {

View File

@ -14,7 +14,7 @@ type PasswordLockoutPolicyReadModel struct {
policy.PasswordLockoutPolicyReadModel policy.PasswordLockoutPolicyReadModel
} }
func (rm *PasswordLockoutPolicyReadModel) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *PasswordLockoutPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
for _, event := range events { for _, event := range events {
switch e := event.(type) { switch e := event.(type) {
case *PasswordLockoutPolicyAddedEvent: case *PasswordLockoutPolicyAddedEvent:
@ -25,7 +25,6 @@ func (rm *PasswordLockoutPolicyReadModel) AppendEvents(events ...eventstore.Even
rm.ReadModel.AppendEvents(e) rm.ReadModel.AppendEvents(e)
} }
} }
return nil
} }
type PasswordLockoutPolicyAddedEvent struct { type PasswordLockoutPolicyAddedEvent struct {

View File

@ -17,9 +17,8 @@ type IAM struct {
// TODO: how to implement queries? // TODO: how to implement queries?
} }
func (rm *IAM) AppendEvents(events ...eventstore.EventReader) (err error) { func (rm *IAM) AppendEvents(events ...eventstore.EventReader) {
rm.ReadModel.AppendEvents(events...) rm.ReadModel.AppendEvents(events...)
return err
} }
//Reduce implements eventstore.ReadModel //Reduce implements eventstore.ReadModel