client

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package client holds client domain logic

Package client holds client domain logic

Index

Constants

This section is empty.

Variables

View Source
var StreamName = fmt.Sprintf("%T", Client{})

StreamName for client domain

Functions

func OnCreate

func OnCreate(repository Repository, db *sql.DB) commandbus.CommandHandler

OnCreate creates command handler

func OnRemove

func OnRemove(repository Repository, db *sql.DB) commandbus.CommandHandler

OnRemove creates command handler

Types

type Client

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

Client aggregate root

func FromHistory

func FromHistory(events []domain.Event) Client

FromHistory loads current aggregate root state by applying all events in order

func New

func New() Client

New creates an Client

func (Client) Changes

func (c Client) Changes() []domain.Event

Changes returns all new applied events

func (*Client) Create

func (c *Client) Create(info oauth2.ClientInfo) error

Create alters current client state and append changes to aggregate root

func (Client) ID

func (c Client) ID() uuid.UUID

ID returns aggregate root id

func (*Client) Remove

func (c *Client) Remove() error

Remove alters current client state and append changes to aggregate root

func (Client) Version

func (c Client) Version() int

Version returns current aggregate root version

type Create

type Create struct {
	ClientInfo oauth2.ClientInfo
}

Create command

func (Create) GetName

func (c Create) GetName() string

GetName returns command name

type Remove

type Remove struct {
	ID uuid.UUID `json:"id"`
}

Remove command

func (Remove) GetName

func (c Remove) GetName() string

GetName returns command name

type Repository

type Repository interface {
	Save(ctx context.Context, c Client) error
	Get(id uuid.UUID) Client
}

Repository allows to get/save events from/to event store

type WasCreated

type WasCreated struct {
	ID     uuid.UUID `json:"id"`
	UserID uuid.UUID `json:"userId"`
	Secret string
	Domain string

	Data json.RawMessage `json:"data"`
}

WasCreated event

func (WasCreated) GetType

func (e WasCreated) GetType() string

GetType returns event type

type WasRemoved

type WasRemoved struct {
	ID uuid.UUID `json:"id"`
}

WasRemoved event

func (WasRemoved) GetType

func (e WasRemoved) GetType() string

GetType returns event type

Jump to

Keyboard shortcuts

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