models

package
v0.0.0-...-fe3b579 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeString

func EncodeString(s string) string

func Exists

func Exists(file string) bool

func GetEnv

func GetEnv() string

func NewULID

func NewULID() ulid.ULID

func ReadFile

func ReadFile(file string, obj interface{}) ([]byte, error)

func ReadFileLines

func ReadFileLines(file string) ([]string, error)

func WriteFile

func WriteFile(file string, obj interface{}) error

Types

type Aggregate

type Aggregate struct {
	Id        string
	Type      string
	Version   int64
	Data      interface{}
	Events    []IEvent
	CreatedAt time.Time
	UpdatedAt time.Time
	// contains filtered or unexported fields
}

func NewAggregate

func NewAggregate(id string, typ string, data interface{}) *Aggregate

func (*Aggregate) AddEventHandler

func (a *Aggregate) AddEventHandler(name string, function func(*Aggregate, IEvent) error)

func (*Aggregate) Causes

func (a *Aggregate) Causes(event IEvent) error

type AppConfig

type AppConfig struct {
	EventSourcing *EventSourcingConfig `json:"event-sourcing"`
}

AppConfig ...

func NewConfig

func NewConfig() (*AppConfig, manager.IConfig, error)

NewConfig ...

type Event

type Event struct {
	Id        ulid.ULID
	Name      string
	Data      interface{}
	CreatedAt time.Time
}

func (*Event) GetCreatedAt

func (e *Event) GetCreatedAt() time.Time

func (*Event) GetData

func (e *Event) GetData() interface{}

func (*Event) GetId

func (e *Event) GetId() ulid.ULID

func (*Event) GetName

func (e *Event) GetName() string

type EventSourcing

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

func NewEventSourcing

func NewEventSourcing(options ...EventSourcingOption) (*EventSourcing, error)

func (*EventSourcing) Reconfigure

func (es *EventSourcing) Reconfigure(options ...EventSourcingOption)

Reconfigure ...

func (*EventSourcing) Save

func (es *EventSourcing) Save(aggregate *Aggregate) (err error)

type EventSourcingConfig

type EventSourcingConfig struct {
	Db        manager.DBConfig         `json:"db"`
	Migration services.MigrationConfig `json:"migration"`
	Log       struct {
		Level string `json:"level"`
	} `json:"log"`
}

UploaderConfig ...

type EventSourcingOption

type EventSourcingOption func(es *EventSourcing)

EventSourcingOption ...

func WithConfiguration

func WithConfiguration(config *EventSourcingConfig) EventSourcingOption

WithConfiguration ...

func WithLogLevel

func WithLogLevel(level logger.Level) EventSourcingOption

WithLogLevel ...

func WithLogger

func WithLogger(l logger.ILogger) EventSourcingOption

WithLogger ...

func WithManager

func WithManager(mgr *manager.Manager) EventSourcingOption

WithManager ...

type EventsType

type EventsType map[string]func(*Aggregate, IEvent) error

type IEvent

type IEvent interface {
	GetId() ulid.ULID
	GetName() string
	GetData() interface{}
	GetCreatedAt() time.Time
}

type IStorage

type IStorage interface {
	GetAggregate(id, typ string, obj interface{}) (aggregate *Aggregate, err error)
	StoreAggregate(aggregate *Aggregate) (err error)
}

type Storage

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

func NewStorage

func NewStorage(db *sql.DB, logger logger.ILogger) *Storage

func (*Storage) GetAggregate

func (s *Storage) GetAggregate(id, typ string, obj interface{}) (*Aggregate, error)

func (*Storage) StoreAggregate

func (s *Storage) StoreAggregate(aggregate *Aggregate) (err error)

Jump to

Keyboard shortcuts

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