models

package
v0.0.0-...-860e413 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Columns_Event = iota
	Columns_Max_Sequence
	Columns_InstanceIDs
)

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
	InstanceID       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
	Field_InstanceID
)

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:"-"`
	InstanceID    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
	Operation_NotIn
)

type Query

type Query struct {
	Filters []*Filter
	// contains filtered or unexported fields
}

func (*Query) AggregateIDFilter

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

func (*Query) AggregateIDsFilter

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

func (*Query) AggregateTypeFilter

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

func (*Query) CreationDateNewerFilter

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

func (*Query) EventTypesFilter

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

func (*Query) ExcludedInstanceIDsFilter

func (q *Query) ExcludedInstanceIDsFilter(instanceIDs ...string) *Query

func (*Query) InstanceIDFilter

func (q *Query) InstanceIDFilter(instanceID string) *Query

func (*Query) LatestSequenceFilter

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

func (*Query) ResourceOwnerFilter

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

func (*Query) SearchQuery

func (q *Query) SearchQuery() *SearchQuery

SearchQuery returns the SearchQuery of the sub query

func (*Query) SequenceBetween

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

type SearchQuery

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

SearchQuery is deprecated. Use SearchQueryFactory

func NewSearchQuery

func NewSearchQuery() *SearchQuery

NewSearchQuery is deprecated. Use SearchQueryFactory

func (*SearchQuery) AddQuery

func (q *SearchQuery) AddQuery() *Query

func (*SearchQuery) OrderAsc

func (q *SearchQuery) OrderAsc() *SearchQuery

func (*SearchQuery) OrderDesc

func (q *SearchQuery) OrderDesc() *SearchQuery

func (*SearchQuery) SetColumn

func (q *SearchQuery) SetColumn(columns Columns) *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(q *SearchQuery) *SearchQueryFactory

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

func NewSearchQueryFactory

func NewSearchQueryFactory() *SearchQueryFactory

func (*SearchQueryFactory) AddQuery

func (factory *SearchQueryFactory) AddQuery() *query

func (*SearchQueryFactory) Build

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

func (*SearchQueryFactory) Columns

func (factory *SearchQueryFactory) Columns(columns Columns) *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

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