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

package token

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

Package token holds token domain logic

Package token holds token domain logic

Index

Package Files

commands.go events.go json.go repository.go token.go

Variables

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

StreamName for token domain

func OnCreate Uses

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

OnCreate creates command handler

func OnRemove Uses

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

OnRemove creates command handler

type Create Uses

type Create struct {
    TokenInfo oauth2.TokenInfo
}

Create command

func (Create) GetName Uses

func (c Create) GetName() string

GetName returns command name

type Remove Uses

type Remove struct {
    ID uuid.UUID
}

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, t Token) error
    Get(id uuid.UUID) Token
}

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

type Token Uses

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

Token aggregate root

func FromHistory Uses

func FromHistory(events []domain.Event) Token

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

func New Uses

func New() Token

New creates an Token

func (Token) Changes Uses

func (t Token) Changes() []domain.Event

Changes returns all new applied events

func (*Token) Create Uses

func (t *Token) Create(id uuid.UUID, info oauth2.TokenInfo) error

Create alters current token state and append changes to aggregate root

func (Token) ID Uses

func (t Token) ID() uuid.UUID

ID returns aggregate root id

func (*Token) Remove Uses

func (t *Token) Remove() error

Remove alters current token state and append changes to aggregate root

func (Token) Version Uses

func (t Token) Version() int

Version returns current aggregate root version

type WasCreated Uses

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

    ClientID uuid.UUID `json:"clientId"`
    UserID   uuid.UUID `json:"userId"`
    Code     string    `json:"code"`
    Scope    string    `json:"scope"`
    Access   string    `json:"access"`
    Refresh  string    `json:"refresh"`

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

WasCreated event

func (WasCreated) GetType Uses

func (e WasCreated) GetType() string

GetType returns event type

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 token imports 13 packages (graph) and is imported by 4 packages. Updated 2020-06-26. Refresh now. Tools for package owners.