Documentation ¶
Overview ¶
Package token holds token domain logic
Index ¶
- Constants
- Variables
- func NewCommandFromPayload(contract string, payload []byte) (domain.Command, error)
- func OnCreate(repository Repository) commandbus.CommandHandler
- func OnRemove(repository Repository) commandbus.CommandHandler
- type Create
- type Remove
- type Repository
- type Token
- type WasCreated
- type WasRemoved
Constants ¶
View Source
const ( // CreateAuthToken command bus contract CreateAuthToken = "token-create" // RemoveAuthToken command bus contract RemoveAuthToken = "token-remove" )
Variables ¶
View Source
var ( RemoveName = (Remove{}).GetName() CreateName = (Create{}).GetName() )
View Source
var ( WasCreatedType = (WasCreated{}).GetType() WasRemovedType = (WasRemoved{}).GetType() )
View Source
var StreamName = fmt.Sprintf("%T", Token{})
StreamName for token domain
Functions ¶
func NewCommandFromPayload ¶
NewCommandFromPayload builds command by contract from json payload
func OnCreate ¶
func OnCreate(repository Repository) commandbus.CommandHandler
OnCreate creates command handler
func OnRemove ¶
func OnRemove(repository Repository) commandbus.CommandHandler
OnRemove creates command handler
Types ¶
type Repository ¶
type Repository interface { Save(ctx context.Context, t Token) error Get(ctx context.Context, id uuid.UUID) (Token, error) }
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 ¶
FromHistory loads current aggregate root state by applying all events in order
func (*Token) Create ¶
func (t *Token) Create( ctx context.Context, id uuid.UUID, clientID uuid.UUID, userID uuid.UUID, info oauth2.TokenInfo, userAgent string, ) error
Create alters current token state and append changes to aggregate root
type WasCreated ¶
type WasCreated struct { ID uuid.UUID `json:"id" bson:"id"` ClientID uuid.UUID `json:"client_id" bson:"client_id"` UserID uuid.UUID `json:"user_id" bson:"user_id"` Data json.RawMessage `json:"data" bson:"data"` UserAgent string `json:"user_agent" bson:"user_agent"` }
WasCreated event
func (*WasCreated) GetData ¶
func (e *WasCreated) GetData() json.RawMessage
func (*WasCreated) GetUserAgent ¶
func (e *WasCreated) GetUserAgent() string
func (*WasCreated) TokenInfo ¶
func (e *WasCreated) TokenInfo() (oauth2.TokenInfo, error)
type WasRemoved ¶
WasRemoved event
Click to show internal directories.
Click to hide internal directories.