command

package
v0.0.0-...-2c61642 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2021 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Overview

Command running interface => command gets some context, raises some events when it runs

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Allocators

type Allocators map[string]func() Command

map keyed by command name (command.Key()) values are functions that allocates a new specific command struct

type Command

type Command interface {
	Key() string
	Validate() error
	MiddlewareChain() string
}

type Ctx

type Ctx struct {
	Ctx context.Context // Go's cancellation context

	Meta ehevent.EventMeta

	RemoteAddr string
	UserAgent  string
	// contains filtered or unexported fields
}

context for invoking command

func NewCtx

func NewCtx(
	ctx context.Context,
	meta ehevent.EventMeta,
	remoteAddr string,
	userAgent string,
) *Ctx

func (*Ctx) AddCookie

func (c *Ctx) AddCookie(cookie *http.Cookie)

func (*Ctx) Cookies

func (c *Ctx) Cookies() []*http.Cookie

func (*Ctx) CreatedRecordId

func (c *Ctx) CreatedRecordId(id string)

func (*Ctx) GetCreatedRecordId

func (c *Ctx) GetCreatedRecordId() string

func (*Ctx) GetRaisedEvents

func (c *Ctx) GetRaisedEvents() []ehevent.Event

func (*Ctx) RaisesEvent

func (c *Ctx) RaisesEvent(event ehevent.Event)

type Invoker

type Invoker interface {
	Invoke(cmdGeneric Command, ctx *Ctx) error
}

can invoke any command in typesafe manner

Jump to

Keyboard shortcuts

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