try splitt event

This commit is contained in:
adlerhurst
2020-11-06 13:47:27 +01:00
parent 756a4f1d08
commit f4bd5ddcbc
9 changed files with 428 additions and 245 deletions
+25 -31
View File
@@ -2,18 +2,12 @@ package eventstore
import (
"time"
"github.com/caos/zitadel/internal/eventstore/v2/repository"
)
//Event is the representation of a state change
type Event interface {
//CheckPrevious ensures the event order if true
// if false the previous sequence is not checked on push
CheckPrevious() bool
//EditorService must return the name of the service which creates the new event
type EventPusher interface {
// EditorService is the service who wants to push the event
EditorService() string
//EditorUser must return the id of the user who created the event
//EditorUser is the user who wants to push the event
EditorUser() string
//Type must return an event type which should be unique in the aggregate
Type() EventType
@@ -24,30 +18,30 @@ type Event interface {
// * struct which can be marshalled to json
// * pointer to struct which can be marshalled to json
Data() interface{}
//MetaData returns all data saved on a event
// It must not be set on push
// The event mapper function must set this struct
MetaData() *EventMetaData
//CheckPrevious ensures the event order if true
// if false the previous sequence is not checked on push
CheckPrevious() bool
}
func MetaDataFromRepo(event *repository.Event) *EventMetaData {
return &EventMetaData{
AggregateID: event.AggregateID,
AggregateType: AggregateType(event.AggregateType),
AggregateVersion: Version(event.Version),
PreviouseSequence: event.PreviousSequence,
ResourceOwner: event.ResourceOwner,
Sequence: event.Sequence,
CreationDate: event.CreationDate,
}
type EventReader interface {
// EditorService is the service who pushed the event
EditorService() string
//EditorUser is the user who pushed the event
EditorUser() string
//Type is the type of the event
Type() EventType
AggregateID() string
AggregateType() AggregateType
ResourceOwner() string
AggregateVersion() Version
Sequence() uint64
PreviousSequence() uint64
CreationDate() time.Time
}
type EventMetaData struct {
AggregateID string
AggregateType AggregateType
ResourceOwner string
AggregateVersion Version
Sequence uint64
PreviouseSequence uint64
CreationDate time.Time
//Event is the representation of a state change
type Event interface {
EventPusher
EventReader
}