models

package
v1.45.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Columns_Event = iota
	Columns_Max_Sequence
)

Variables

This section is empty.

Functions

func OverwriteEditorUser

func OverwriteEditorUser(userID string) func(*Aggregate)

func OverwriteResourceOwner

func OverwriteResourceOwner(resourceOwner string) func(*Aggregate)

Types

type Aggregate

type Aggregate struct {
	ID string

	PreviousSequence uint64

	Events       []*Event
	Precondition *precondition
	// contains filtered or unexported fields
}

func (*Aggregate) AppendEvent

func (a *Aggregate) AppendEvent(typ EventType, payload interface{}) (*Aggregate, error)

func (*Aggregate) SetPrecondition

func (a *Aggregate) SetPrecondition(query *SearchQuery, validateFunc func(...*Event) error) *Aggregate

func (*Aggregate) Type

func (a *Aggregate) Type() AggregateType

func (*Aggregate) Validate

func (a *Aggregate) Validate() error

type AggregateCreator

type AggregateCreator struct {
	// contains filtered or unexported fields
}

func NewAggregateCreator

func NewAggregateCreator(serviceName string) *AggregateCreator

func (*AggregateCreator) NewAggregate

func (c *AggregateCreator) NewAggregate(ctx context.Context, id string, typ AggregateType, version Version, previousSequence uint64, opts ...option) (*Aggregate, error)

type AggregateType

type AggregateType string

func (AggregateType) String

func (at AggregateType) String() string

type Aggregates

type Aggregates []*Aggregate

type Columns

type Columns int32

type Event

type Event struct {
	ID               string
	Sequence         uint64
	CreationDate     time.Time
	Type             EventType
	PreviousSequence uint64
	Data             []byte

	AggregateID      string
	AggregateType    AggregateType
	AggregateVersion Version
	EditorService    string
	EditorUser       string
	ResourceOwner    string
}

func (*Event) Validate

func (e *Event) Validate() error

type EventType

type EventType string

func (EventType) String

func (et EventType) String() string

type Field

type Field int32
const (
	Field_AggregateType Field = 1 + iota
	Field_AggregateID
	Field_LatestSequence
	Field_ResourceOwner
	Field_EditorService
	Field_EditorUser
	Field_EventType
	Field_CreationDate
)

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

func NewFilter

func NewFilter(field Field, value interface{}, operation Operation) *Filter

NewFilter is used in tests. Use searchQuery.*Filter() instead

func (*Filter) GetField

func (f *Filter) GetField() Field

func (*Filter) GetOperation

func (f *Filter) GetOperation() Operation

func (*Filter) GetValue

func (f *Filter) GetValue() interface{}

func (*Filter) Validate

func (f *Filter) Validate() error

type ObjectRoot

type ObjectRoot struct {
	AggregateID   string    `json:"-"`
	Sequence      uint64    `json:"-"`
	ResourceOwner string    `json:"-"`
	CreationDate  time.Time `json:"-"`
	ChangeDate    time.Time `json:"-"`
}

func (*ObjectRoot) AppendEvent

func (o *ObjectRoot) AppendEvent(event *Event)

func (*ObjectRoot) IsZero

func (o *ObjectRoot) IsZero() bool

type Operation

type Operation int32
const (
	Operation_Equals Operation = 1 + iota
	Operation_Greater
	Operation_Less
	Operation_In
)

type SearchQuery

type SearchQuery struct {
	Limit   uint64
	Desc    bool
	Filters []*Filter
}

SearchQuery is deprecated. Use SearchQueryFactory

func NewSearchQuery

func NewSearchQuery() *SearchQuery

NewSearchQuery is deprecated. Use SearchQueryFactory

func (*SearchQuery) AggregateIDFilter

func (q *SearchQuery) AggregateIDFilter(id string) *SearchQuery

func (*SearchQuery) AggregateIDsFilter

func (q *SearchQuery) AggregateIDsFilter(ids ...string) *SearchQuery

func (*SearchQuery) AggregateTypeFilter

func (q *SearchQuery) AggregateTypeFilter(types ...AggregateType) *SearchQuery

func (*SearchQuery) CreationDateNewerFilter

func (q *SearchQuery) CreationDateNewerFilter(time time.Time) *SearchQuery

func (*SearchQuery) EventTypesFilter

func (q *SearchQuery) EventTypesFilter(types ...EventType) *SearchQuery

func (*SearchQuery) LatestSequenceFilter

func (q *SearchQuery) LatestSequenceFilter(sequence uint64) *SearchQuery

func (*SearchQuery) OrderAsc

func (q *SearchQuery) OrderAsc() *SearchQuery

func (*SearchQuery) OrderDesc

func (q *SearchQuery) OrderDesc() *SearchQuery

func (*SearchQuery) ResourceOwnerFilter

func (q *SearchQuery) ResourceOwnerFilter(resourceOwner string) *SearchQuery

func (*SearchQuery) SequenceBetween

func (q *SearchQuery) SequenceBetween(from, to uint64) *SearchQuery

func (*SearchQuery) SetLimit

func (q *SearchQuery) SetLimit(limit uint64) *SearchQuery

func (*SearchQuery) Validate

func (q *SearchQuery) Validate() error

type SearchQueryFactory

type SearchQueryFactory struct {
	// contains filtered or unexported fields
}

func FactoryFromSearchQuery

func FactoryFromSearchQuery(query *SearchQuery) *SearchQueryFactory

FactoryFromSearchQuery is deprecated because it's for migration purposes. use NewSearchQueryFactory

func NewSearchQueryFactory

func NewSearchQueryFactory(aggregateTypes ...AggregateType) *SearchQueryFactory

func (*SearchQueryFactory) AggregateIDs

func (factory *SearchQueryFactory) AggregateIDs(ids ...string) *SearchQueryFactory

func (*SearchQueryFactory) Build

func (factory *SearchQueryFactory) Build() (*searchQuery, error)

func (*SearchQueryFactory) Columns

func (factory *SearchQueryFactory) Columns(columns Columns) *SearchQueryFactory

func (*SearchQueryFactory) CreationDateNewer

func (factory *SearchQueryFactory) CreationDateNewer(time time.Time) *SearchQueryFactory

func (*SearchQueryFactory) EventTypes

func (factory *SearchQueryFactory) EventTypes(types ...EventType) *SearchQueryFactory

func (*SearchQueryFactory) Limit

func (factory *SearchQueryFactory) Limit(limit uint64) *SearchQueryFactory

func (*SearchQueryFactory) OrderAsc

func (factory *SearchQueryFactory) OrderAsc() *SearchQueryFactory

func (*SearchQueryFactory) OrderDesc

func (factory *SearchQueryFactory) OrderDesc() *SearchQueryFactory

func (*SearchQueryFactory) ResourceOwner

func (factory *SearchQueryFactory) ResourceOwner(resourceOwner string) *SearchQueryFactory

func (*SearchQueryFactory) SequenceGreater

func (factory *SearchQueryFactory) SequenceGreater(sequence uint64) *SearchQueryFactory

func (*SearchQueryFactory) SequenceLess

func (factory *SearchQueryFactory) SequenceLess(sequence uint64) *SearchQueryFactory

type Version

type Version string

func (Version) String

func (v Version) String() string

func (Version) Validate

func (v Version) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL