model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package model provides structs (models) used commonly through services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

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

Cmd represents a Command. Use #NewCmd to create new instance.

func NewCmd

func NewCmd(cfg *CmdCfg) (Cmd, error)

NewCmd validates provided config and creates a new Cmd. Uses current UTC-time if time is not set.

func (Cmd) Action

func (c Cmd) Action() CmdAction

Action return Command-Action.

func (Cmd) CorrelationKey

func (c Cmd) CorrelationKey() string

CorrelationKey returns Command-CorrelationKey.

func (Cmd) Data

func (c Cmd) Data() []byte

Data return Command-Data.

func (Cmd) ID

func (c Cmd) ID() string

ID returns Command-ID.

func (Cmd) Time

func (c Cmd) Time() time.Time

Time return Command-Time.

type CmdAction

type CmdAction string

CmdAction represents a Command-action.

const (
	CreateTxn    CmdAction = "CreateTxn"
	ProcessTxn   CmdAction = "ProcessTxn"
	CreateReport CmdAction = "CreateReport"
	WriteData    CmdAction = "WriteData"
)

Domain commands

func (CmdAction) String

func (ca CmdAction) String() string

String returns string-representation of a CmdAction.

type CmdCfg

type CmdCfg struct {
	CorrelationKey string

	Time   time.Time
	Action CmdAction `validate:"nonzero"`
	Data   interface{}
}

CmdCfg is config for Cmd.

type Event

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

Event represents a Command. Use #NewEvent to create new instance.

func NewEvent

func NewEvent(cfg *EventCfg) (Event, error)

NewEvent validates provided config and creates a new Event. Uses current UTC-time if time is not set.

func (Event) Action

func (e Event) Action() EventAction

Action return Event-Action.

func (Event) AggregateID

func (e Event) AggregateID() string

AggregateID return Event-AggregateID.

func (Event) CorrelationKey

func (e Event) CorrelationKey() string

CorrelationKey return Event-CorrelationKey.

func (Event) Data

func (e Event) Data() []byte

Data return Event-Data.

func (Event) ID

func (e Event) ID() string

ID return Event-ID.

func (Event) IsReplay

func (e Event) IsReplay() bool

IsReplay return Event-IsReplay.

func (Event) Time

func (e Event) Time() time.Time

Time return Event-Time.

type EventAction

type EventAction string

EventAction represents an Event-action.

const (
	TxnRead EventAction = "TxnRead"

	TxnCreated      EventAction = "TxnCreated"
	TxnCreateFailed EventAction = "TxnCreateFailed"

	AccountDeposited     EventAction = "AccountDeposited"
	AccountWithdrawn     EventAction = "AccountWithdrawn"
	AccountLimitExceeded EventAction = "AccountLimitExceeded"
	DuplicateTxn         EventAction = "DuplicateTxn"

	DataWritten EventAction = "DataWritten"
)

Domain events

func (EventAction) String

func (ea EventAction) String() string

String returns string-representation of a EventAction.

type EventCfg

type EventCfg struct {
	AggregateID    string `validate:"nonzero"`
	CorrelationKey string

	Time     time.Time
	Action   EventAction `validate:"nonzero"`
	Data     interface{}
	IsReplay bool
}

EventCfg is config for Event.

type Transaction

type Transaction struct {
	ID         string    `json:"id"`
	CustomerID string    `json:"customer_id"`
	LoadAmount float64   `json:"load_amount"`
	Time       time.Time `json:"time"`
}

Transaction represents a single account-Transaction.

Jump to

Keyboard shortcuts

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