zitadel/internal/eventstore/v2/repository/event.go

69 lines
2.2 KiB
Go
Raw Normal View History

2020-09-30 08:00:05 +00:00
package repository
2020-09-24 06:52:10 +00:00
2020-09-30 08:00:05 +00:00
import (
"database/sql"
2020-09-30 08:00:05 +00:00
"time"
)
2020-09-24 06:52:10 +00:00
//Event represents all information about a manipulation of an aggregate
type Event struct {
//ID is a generated uuid for this event
ID string
//Sequence is the sequence of the event
Sequence uint64
2020-09-24 06:52:10 +00:00
//PreviousSequence is the sequence of the previous sequence
// if it's 0 then it's the first event of this aggregate
PreviousSequence uint64
2020-09-30 08:00:05 +00:00
//PreviousEvent is needed in push to update PreviousSequence
// it implements a linked list
PreviousEvent *Event
//CheckPreviousSequence decides if the event can only be written
// if event.PreviousSequence == max(event_sequence) of this aggregate
CheckPreviousSequence bool
2020-09-24 06:52:10 +00:00
//CreationDate is the time the event is created
// it's used for human readability.
// Don't use it for event ordering,
// time drifts in different services could cause integrity problems
CreationDate time.Time
//Type describes the cause of the event (e.g. user.added)
// it should always be in past-form
Type EventType
//Data describe the changed fields (e.g. userName = "hodor")
// data must always a pointer to a struct, a struct or a byte array containing json bytes
Data []byte
2020-09-24 06:52:10 +00:00
//EditorService should be a unique identifier for the service which created the event
// it's meant for maintainability
EditorService string
//EditorUser should be a unique identifier for the user which created the event
// it's meant for maintainability.
// It's recommend to use the aggregate id of the user
EditorUser string
//Version describes the definition of the aggregate at a certain point in time
// it's used in read models to reduce the events in the correct definition
Version Version
//AggregateID id is the unique identifier of the aggregate
// the client must generate it by it's own
AggregateID string
//AggregateType describes the meaning of the aggregate for this event
// it could an object like user
AggregateType AggregateType
//ResourceOwner is the organisation which owns this aggregate
// an aggregate can only be managed by one organisation
// use the ID of the org
ResourceOwner string
stmt *sql.Stmt
2020-09-24 06:52:10 +00:00
}
//EventType is the description of the change
type EventType string