go-api-boilerplate: github.com/vardius/go-api-boilerplate/cmd/auth/internal/domain/client Index | Files

package client

import "github.com/vardius/go-api-boilerplate/cmd/auth/internal/domain/client"

Package client holds client domain logic

Index

Package Files

client.go commands.go events.go repository.go

Constants

const (
    // CreateClientCredentials command bus contract
    CreateClientCredentials = "create-client-credentials"
    // RemoveClientCredentials command bus contract
    RemoveClientCredentials = "remove-client-credentials"
)

Variables

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

StreamName for client domain

func NewCommandFromPayload Uses

func NewCommandFromPayload(contract string, payload []byte) (domain.Command, error)

NewCommandFromPayload builds command by contract from json payload

func OnCreate Uses

func OnCreate(repository Repository) commandbus.CommandHandler

OnCreate creates command handler

func OnRemove Uses

func OnRemove(repository Repository) commandbus.CommandHandler

OnRemove creates command handler

type Client Uses

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

Client aggregate root

func FromHistory Uses

func FromHistory(ctx context.Context, events []domain.Event) (Client, error)

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

func New Uses

func New() Client

New creates an Client

func (Client) Changes Uses

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

Changes returns all new applied events

func (*Client) Create Uses

func (c *Client) Create(
    ctx context.Context,
    clientID uuid.UUID,
    clientSecret uuid.UUID,
    userID uuid.UUID,
    domainName string,
    redirectURL string,
    scopes ...string,
) error

Create alters current client state and append changes to aggregate root

func (Client) ID Uses

func (c Client) ID() uuid.UUID

ID returns aggregate root id

func (*Client) Remove Uses

func (c *Client) Remove(ctx context.Context) error

Remove alters current client state and append changes to aggregate root

func (Client) Version Uses

func (c Client) Version() int

Version returns current aggregate root version

type Create Uses

type Create struct {
    Domain      string   `json:"domain"`
    RedirectURL string   `json:"redirect_url"`
    Scopes      []string `json:"scopes"`
}

Create command

func (Create) GetName Uses

func (c Create) GetName() string

GetName returns command name

type Remove Uses

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

Remove command

func (Remove) GetName Uses

func (c Remove) GetName() string

GetName returns command name

type Repository Uses

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

    // Block and returns after event handlers are finished
    SaveAndAcknowledge(ctx context.Context, c Client) error
}

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

type WasCreated Uses

type WasCreated struct {
    ID          uuid.UUID `json:"id"`
    UserID      uuid.UUID `json:"user_id"`
    Secret      uuid.UUID `json:"secret"`
    Domain      string    `json:"domain"`
    RedirectURL string    `json:"redirect_url"`
    Scopes      []string  `json:"scopes"`
}

WasCreated event

func (WasCreated) GetDomain Uses

func (e WasCreated) GetDomain() string

GetDomain client domain

func (WasCreated) GetID Uses

func (e WasCreated) GetID() string

GetID client id

func (WasCreated) GetRedirectURL Uses

func (e WasCreated) GetRedirectURL() string

GetRedirectURL user id

func (WasCreated) GetScopes Uses

func (e WasCreated) GetScopes() []string

GetScopes user id

func (WasCreated) GetSecret Uses

func (e WasCreated) GetSecret() string

GetSecret client domain

func (WasCreated) GetType Uses

func (e WasCreated) GetType() string

GetType returns event type

func (WasCreated) GetUserID Uses

func (e WasCreated) GetUserID() string

GetUserID user id

type WasRemoved Uses

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

WasRemoved event

func (WasRemoved) GetType Uses

func (e WasRemoved) GetType() string

GetType returns event type

Package client imports 12 packages (graph) and is imported by 3 packages. Updated 2020-12-06. Refresh now. Tools for package owners.