Back to godoc.org

Package token

v0.0.0
Latest Go to latest

The latest major version is .

Published: Jul 11, 2020 | License: MIT | Module: github.com/vardius/go-api-boilerplate

Overview

Package token holds token domain logic

Package token holds token domain logic

Index

Variables

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

StreamName for token domain

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

type Create

type Create struct {
	TokenInfo oauth2.TokenInfo
}

Create command

func (Create) GetName

func (c Create) GetName() string

GetName returns command name

type Remove

type Remove struct {
	ID uuid.UUID
}

Remove command

func (Remove) GetName

func (c Remove) GetName() string

GetName returns command name

type Repository

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

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

Token aggregate root

func FromHistory

func FromHistory(events []domain.Event) Token

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

func New

func New() Token

New creates an Token

func (Token) Changes

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

Changes returns all new applied events

func (*Token) Create

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

func (t Token) ID() uuid.UUID

ID returns aggregate root id

func (*Token) Remove

func (t *Token) Remove() error

Remove alters current token state and append changes to aggregate root

func (Token) Version

func (t Token) Version() int

Version returns current aggregate root version

type WasCreated

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

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier