Documentation
¶
Overview ¶
Package kitchen A golang framework for building progressive backend services.
Index ¶
- Variables
- func GroupPrefork[D ICookware](ctx context.Context, concurrent, buffer int, ...)
- func InitMenu[W iMenu[D], D ICookware](menuPtr W, bundle any) W
- func InitPipeline[D IPipelineCookware[M], M IPipelineModel, P iPipeline[D, M]](pipelinePtr P, dep D) P
- func NewOtelTraceableCookware[D ICookware](t trace.Tracer) *otelTraceableCookware[D]
- func NewWebContext(ctx context.Context, bundle IWebBundle, cookware ICookware) *webContext
- type AfterListenHandlers
- type ChainTraceableCookware
- type Context
- func (c Context[D]) Cookware() D
- func (c Context[D]) Dependency() D
- func (c Context[D]) Dish() iDish[D]
- func (c Context[D]) GetCtx() context.Context
- func (c Context[D]) Menu() iMenu[D]
- func (c Context[D]) RawCookware() ICookware
- func (c *Context[D]) Session(nodes ...IDishServe) []IDishServe
- func (c *Context[D]) SetCtx(ctx context.Context)
- func (c Context[D]) Sets() []iSet[D]
- func (c *Context[D]) TraceSpan() iTraceSpan[D]
- func (c Context[D]) WebBundle() IWebBundle
- type ContextForTest
- func (c ContextForTest[D]) Cookware() D
- func (c ContextForTest[D]) Dependency() D
- func (c ContextForTest[D]) Dish() iDish[D]
- func (c ContextForTest[D]) GetCtx() context.Context
- func (c ContextForTest[D]) Menu() iMenu[D]
- func (c ContextForTest[D]) RawCookware() ICookware
- func (c *ContextForTest[D]) Session(serve ...IDishServe) []IDishServe
- func (c ContextForTest[D]) SetCtx(ctx context.Context)
- func (c *ContextForTest[D]) SetWebBundle(body []byte, bundle IWebBundle)
- func (c ContextForTest[D]) Sets() []iSet[D]
- func (c ContextForTest[D]) TraceSpan() iTraceSpan[D]
- func (c ContextForTest[D]) WebBundle() IWebBundle
- type CounterTraceableCookware
- type Dish
- func (r *Dish) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *Dish) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *Dish) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *Dish) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *Dish) ConcurrentLimit(limit int32)
- func (a *Dish[D, I, O]) Cook(ctx context.Context, input I) (output O, err error)
- func (a *Dish[D, I, O]) CookAny(ctx context.Context, input any) (output any, err error)
- func (a *Dish[D, I, O]) CookAsync(ctx context.Context, input I, optionalCallback ...func(O, error))
- func (a *Dish[D, I, O]) CookWithCookware(ctx context.Context, cookware D, input I) (output O, err error)
- func (a Dish[D, I, O]) Cookware() ICookware
- func (a Dish[D, I, O]) Dependency() D
- func (a *Dish[D, I, O]) Exec(ctx context.Context, input I) (output O, err error)
- func (a *Dish[D, I, O]) ExecAsync(ctx context.Context, input I, optionalCallback ...func(O, error))
- func (a *Dish[D, I, O]) ExecWithDep(ctx context.Context, dep D, input I) (output O, err error)
- func (a Dish[D, I, O]) FullName() string
- func (a Dish[D, I, O]) IO() (any, any)
- func (a Dish[D, I, O]) Id() uint32
- func (a Dish[D, I, O]) Input() any
- func (a Dish[D, I, O]) Menu() IMenu
- func (a Dish[D, I, O]) Name() string
- func (b Dish) Nodes() []IInstance
- func (a *Dish[D, I, O]) PanicRecover(recover func(iContext IContext[D], recover any)) *Dish[D, I, O]
- func (a *Dish[D, I, O]) Prefork(ctx context.Context, concurrent, buffer int, preHeatCookware ...func() D)
- func (a *Dish[D, I, O]) SetCooker(cooker DishCooker[D, I, O]) *Dish[D, I, O]
- func (a *Dish[D, I, O]) SetExecer(cooker DishCooker[D, I, O]) *Dish[D, I, O]
- func (a Dish[D, I, O]) Sets() []ISet
- func (a Dish[D, I, O]) Tags() reflect.StructTag
- type DishCooker
- type IContext
- type IContextWithSession
- type ICookware
- type ICookwareFactory
- type ICookwareInheritable
- type IDbRunner
- type IDbTx
- type IDish
- type IDishServe
- type IInstance
- type IManager
- type IMenu
- type IPipeline
- type IPipelineAction
- type IPipelineContext
- type IPipelineCookware
- type IPipelineModel
- type IPipelineModelCanMap
- type IPipelineStage
- type ISet
- type ITraceSpan
- type ITraceableCookware
- type IWebBundle
- type Manager
- type MenuBase
- func (r *MenuBase) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *MenuBase) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *MenuBase) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *MenuBase) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *MenuBase) ConcurrentLimit(limit int32)
- func (r MenuBase[W, D]) Cookware() ICookware
- func (b MenuBase[W, D]) Dependency() D
- func (b *MenuBase[W, D]) Dishes() []iDish[D]
- func (b *MenuBase[W, D]) ID() uint32
- func (b *MenuBase[W, D]) Manager() IManager
- func (b *MenuBase[W, D]) Menu() IMenu
- func (b MenuBase[W, D]) Name() string
- func (b MenuBase) Nodes() []IInstance
- type MenuCounter
- type PipelineAction
- func (r *PipelineAction) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineAction) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineAction) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineAction) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineAction) ConcurrentLimit(limit int32)
- func (p *PipelineAction[D, M, I, O]) CreateModel() *PipelineAction[D, M, I, O]
- func (p *PipelineAction[D, M, I, O]) ExecById(ctx context.Context, input I, modelId ...any) (output O, err error)
- func (p *PipelineAction[D, M, I, O]) ExecByIdAndDep(ctx context.Context, dep D, input I, modelId ...any) (output O, err error)
- func (p *PipelineAction[D, M, I, O]) ExecByIdAny(ctx context.Context, input any, ids ...any) (output any, err error)
- func (p *PipelineAction[D, M, I, O]) ExecWithModel(ctx context.Context, model M, input I) (output O, err error)
- func (p *PipelineAction[D, M, I, O]) ExecWithModelAndDep(ctx context.Context, dep D, model M, input I) (output O, err error)
- func (p PipelineAction[D, M, I, O]) ModelToMap(model IPipelineModel) map[string]string
- func (b PipelineAction) Nodes() []IInstance
- func (p PipelineAction[D, M, I, O]) Pipeline() IPipeline
- func (p *PipelineAction[D, M, I, O]) SetCooker(cooker PipelineDishCooker[D, M, I, O]) *PipelineAction[D, M, I, O]
- func (p *PipelineAction[D, M, I, O]) SetNextStage(stage IPipelineStage) *PipelineAction[D, M, I, O]
- func (p PipelineAction[D, M, I, O]) Status() PipelineStatus
- func (p *PipelineAction[D, M, I, O]) WillCreateModel() bool
- type PipelineActionInput
- type PipelineActionOutput
- type PipelineBase
- func (r *PipelineBase) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineBase) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineBase) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineBase) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineBase) ConcurrentLimit(limit int32)
- func (p *PipelineBase[P, D, M]) GetActionsForModel(model any) (string, []IPipelineAction)
- func (p *PipelineBase[P, D, M]) GetActionsForStatus(status string) []IPipelineAction
- func (p PipelineBase[P, D, M]) NewModel() IPipelineModel
- func (b PipelineBase) Nodes() []IInstance
- type PipelineContext
- type PipelineContextForTest
- type PipelineDishCooker
- type PipelineStage
- func (ps PipelineStage[D, M]) Actions() []IPipelineAction
- func (r *PipelineStage) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineStage) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineStage) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineStage) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *PipelineStage) ConcurrentLimit(limit int32)
- func (b PipelineStage) Nodes() []IInstance
- func (ps PipelineStage[D, M]) Status() PipelineStatus
- type PipelineStatus
- type SetBase
- func (r *SetBase) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *SetBase) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *SetBase) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *SetBase) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
- func (r *SetBase) ConcurrentLimit(limit int32)
- func (s SetBase[D]) Menu() IMenu
- func (s SetBase[D]) Name() string
- func (b SetBase) Nodes() []IInstance
- func (s *SetBase[D]) OverridePath(path string) *SetBase[D]
- func (s SetBase[D]) Tree() []ISet
- type ZeroLogTraceableCookware
Constants ¶
This section is empty.
Variables ¶
var ErrCookerNotSet = errors.New("cooker not set")
var ErrInvalidStatus = errors.New("invalid pipeline status")
var (
TraceIdGenerator = traceId
)
Functions ¶
func GroupPrefork ¶
func GroupPrefork[D ICookware](ctx context.Context, concurrent, buffer int, preHeatCookwareCanNilMeansUseDefault func() D, dishes ...iDish[D])
GroupPrefork is for preparing for a group of dishes with prefork goroutines if you just want to limit the concurrent number, ConcurrentLimit is always faster prefork is for regulate async goroutines or use preHeatCookware preHeatCookware is useful for delegating resources to each goroutine
func InitMenu ¶
func InitMenu[W iMenu[D], D ICookware](menuPtr W, bundle any) W
InitMenu initializes a menu.
func InitPipeline ¶
func InitPipeline[D IPipelineCookware[M], M IPipelineModel, P iPipeline[D, M]](pipelinePtr P, dep D) P
func NewWebContext ¶
NewWebContext creates a new web context for web router wrappers and prevent the dish context ends after the web request ends.
Types ¶
type AfterListenHandlers ¶
type ChainTraceableCookware ¶
type ChainTraceableCookware[D ICookware] []ITraceableCookware[D]
func NewChainTraceableCookware ¶
func NewChainTraceableCookware[D ICookware](deps ...ITraceableCookware[D]) *ChainTraceableCookware[D]
func (ChainTraceableCookware[D]) StartTrace ¶
func (d ChainTraceableCookware[D]) StartTrace(ctx IContext[D], id string, input any) (context.Context, iTraceSpan[D])
type Context ¶
Context is a struct that holds various information and dependencies needed for the dishes.
func (Context[D]) Dependency ¶
func (c Context[D]) Dependency() D
func (Context[D]) RawCookware ¶
func (c Context[D]) RawCookware() ICookware
func (*Context[D]) Session ¶
func (c *Context[D]) Session(nodes ...IDishServe) []IDishServe
Session Context will pass through nesting call of dishes, this appends sessions and returns all the session of the context.
type ContextForTest ¶
type ContextForTest[D ICookware] struct {
context.Context
SessionServed []IDishServe
DummyCookware D
DummyDish iDish[D]
DummySets []iSet[D]
DummyMenu iMenu[D]
// contains filtered or unexported fields
}
A ContextForTest is for mocking the Context struct for testing.
func (ContextForTest[D]) Cookware ¶
func (c ContextForTest[D]) Cookware() D
func (ContextForTest[D]) Dependency ¶
func (c ContextForTest[D]) Dependency() D
func (ContextForTest[D]) Dish ¶
func (c ContextForTest[D]) Dish() iDish[D]
func (ContextForTest[D]) GetCtx ¶
func (c ContextForTest[D]) GetCtx() context.Context
func (ContextForTest[D]) Menu ¶
func (c ContextForTest[D]) Menu() iMenu[D]
func (ContextForTest[D]) RawCookware ¶
func (c ContextForTest[D]) RawCookware() ICookware
func (*ContextForTest[D]) Session ¶
func (c *ContextForTest[D]) Session(serve ...IDishServe) []IDishServe
func (ContextForTest[D]) SetCtx ¶
func (c ContextForTest[D]) SetCtx(ctx context.Context)
func (*ContextForTest[D]) SetWebBundle ¶
func (c *ContextForTest[D]) SetWebBundle(body []byte, bundle IWebBundle)
func (ContextForTest[D]) Sets ¶
func (c ContextForTest[D]) Sets() []iSet[D]
func (ContextForTest[D]) TraceSpan ¶
func (c ContextForTest[D]) TraceSpan() iTraceSpan[D]
func (ContextForTest[D]) WebBundle ¶
func (c ContextForTest[D]) WebBundle() IWebBundle
type CounterTraceableCookware ¶
type CounterTraceableCookware[D ICookware] struct {
Menus []*MenuCounter
// contains filtered or unexported fields
}
func NewCounterTraceableCookware ¶
func NewCounterTraceableCookware[D ICookware]() *CounterTraceableCookware[D]
func (*CounterTraceableCookware[D]) StartTrace ¶
func (d *CounterTraceableCookware[D]) StartTrace(ctx IContext[D], id string, input any) (context.Context, iTraceSpan[D])
type Dish ¶
A Dish is the placeholder for a function in the menu.
func (*Dish) AfterCook ¶
func (r *Dish) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec registers a handler to be called after the dish has been executed.
func (*Dish) AfterCookAsync ¶
func (r *Dish) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync registers a handler to be called after the dish has been executed asynchronously.
func (*Dish) AfterExec ¶
func (r *Dish) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec aliases of AfterCook
func (*Dish) AfterExecAsync ¶
func (r *Dish) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync aliases of AfterCookAsync
func (*Dish) ConcurrentLimit ¶
func (r *Dish) ConcurrentLimit(limit int32)
ConcurrentLimit sets the maximum number of concurrent executions of this node and it's children.
func (*Dish[D, I, O]) Cook ¶
Cook executes the dish with the input and returns the output and error. Return ErrCookerNotSet if the cooker is not set.
func (*Dish[D, I, O]) CookAny ¶
CookAny is for cooking with any input, mainly for external node calling with network.
func (*Dish[D, I, O]) CookAsync ¶
CookAsync executes the dish asynchronously with the input and optional callback.
func (*Dish[D, I, O]) CookWithCookware ¶
func (a *Dish[D, I, O]) CookWithCookware(ctx context.Context, cookware D, input I) (output O, err error)
CookWithCookware executes the dish with the cookware(dependency) and the input, returns the output and error.
func (Dish[D, I, O]) Cookware ¶
func (a Dish[D, I, O]) Cookware() ICookware
Cookware returns the cookware(dependency) of the dish.
func (Dish[D, I, O]) Dependency ¶
func (a Dish[D, I, O]) Dependency() D
Dependency alias of Cookware
func (*Dish[D, I, O]) ExecWithDep ¶
deprecated use CookWithCookware
func (*Dish[D, I, O]) PanicRecover ¶
func (a *Dish[D, I, O]) PanicRecover(recover func(iContext IContext[D], recover any)) *Dish[D, I, O]
PanicRecover sets the recover function after panic, no recovery if nil.
func (*Dish[D, I, O]) Prefork ¶
func (a *Dish[D, I, O]) Prefork(ctx context.Context, concurrent, buffer int, preHeatCookware ...func() D)
Prefork is for regulating async goroutines or using preHeatCookware
func (*Dish[D, I, O]) SetCooker ¶
func (a *Dish[D, I, O]) SetCooker(cooker DishCooker[D, I, O]) *Dish[D, I, O]
SetCooker sets the function body to be executed when the dish is cooked.
func (*Dish[D, I, O]) SetExecer ¶
func (a *Dish[D, I, O]) SetExecer(cooker DishCooker[D, I, O]) *Dish[D, I, O]
SetExecer is an alias of SetCooker
type DishCooker ¶
type IContext ¶
type IContext[D ICookware] interface { IContextWithSession Menu() iMenu[D] Sets() []iSet[D] Dish() iDish[D] Dependency() D Cookware() D TraceSpan() iTraceSpan[D] // contains filtered or unexported methods }
type IContextWithSession ¶
type ICookwareFactory ¶
type ICookwareInheritable ¶
ICookwareInheritable is a cookware that can be inherited by another cookware. Useful when cross menu cooking is needed and pass the cookware around.
type IDbRunner ¶
type IDbRunner interface {
QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}
type IDish ¶
type IDish interface {
Name() string
FullName() string
Input() any
IO() (any, any)
Id() uint32
Menu() IMenu
Cookware() ICookware
Sets() []ISet
Tags() reflect.StructTag
// CookAny is for cooking with any input, mainly for external node calling with network.
CookAny(ctx context.Context, input any) (output any, err error)
// contains filtered or unexported methods
}
type IDishServe ¶
type IManager ¶
type IManager interface {
AddMenu(menuInitializer func() IMenu) IManager
SetMainKitchen(url string, port uint16) IManager
Init() (IManager, error)
SelectServeMenus(menuNames ...string) IManager
DisableMenu(name string) IManager
// contains filtered or unexported methods
}
IManager is the used for managing menus for scaling.
func NewDeliveryManager ¶
NewDeliveryManager creates a new Manager. localHostUrl is the local host url which typically host from docker/kubernetes. localRepPort is the local port for the manager to listen to and exported for foreign call.
type IPipeline ¶
type IPipeline interface {
IMenu
GetActionsForModel(any) (status string, actions []IPipelineAction)
GetActionsForStatus(status string) []IPipelineAction
NewModel() IPipelineModel
}
type IPipelineAction ¶
type IPipelineContext ¶
type IPipelineContext[D IPipelineCookware[M], M IPipelineModel] interface {
IContext[D]
Tx() IDbTx
Pipeline() iPipeline[D, M]
Stage() iPipelineStage[D, M]
}
type IPipelineCookware ¶
type IPipelineModel ¶
type IPipelineModel interface {
GetStatus() PipelineStatus
SetStatus(status PipelineStatus)
PrimaryKey() any
}
type IPipelineModelCanMap ¶
type IPipelineStage ¶
type IPipelineStage interface {
ISet
Status() PipelineStatus
Actions() []IPipelineAction
}
type ITraceSpan ¶
type ITraceableCookware ¶
type ITraceableCookware[D ICookware] interface { StartTrace(ctx IContext[D], id string, input any) (context.Context, iTraceSpan[D]) }
ITraceableCookware is a cookware that trace the life-cycle of cooking can refer to built in tracers.
type IWebBundle ¶
type IWebBundle interface {
Ctx() context.Context
Method() string
Body() ([]byte, error)
Url() *url.URL
UrlParams() map[string]string
Headers() http.Header
Raw() any
Response() http.ResponseWriter
}
IWebBundle is generated by web router wrapper, it contains all the information of a web request.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
A Manager is a struct for managing menus for scaling.
func (*Manager) AddMenu ¶
func (m *Manager) AddMenu(menuInitializer func() IMenu) IManager
AddMenu adds a menu to the manager. menuInitializer is a function that returns a menu, TODO should like menu to dispose when disabled.
func (*Manager) DisableMenu ¶
DisableMenu disables a menu. should call after Init
func (*Manager) SelectServeMenus ¶
SelectServeMenus selects the menus to serve. not select = serves all should call after Init
func (*Manager) SetMainKitchen ¶
SetMainKitchen sets the main host for the manager.
type MenuBase ¶
type MenuBase[WPtr iMenu[D], D ICookware] struct {
// contains filtered or unexported fields
}
MenuBase is a struct for supporting IMenu, should embed to all menus.
func (*MenuBase) AfterCook ¶
func (r *MenuBase) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec registers a handler to be called after the dish has been executed.
func (*MenuBase) AfterCookAsync ¶
func (r *MenuBase) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync registers a handler to be called after the dish has been executed asynchronously.
func (*MenuBase) AfterExec ¶
func (r *MenuBase) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec aliases of AfterCook
func (*MenuBase) AfterExecAsync ¶
func (r *MenuBase) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync aliases of AfterCookAsync
func (*MenuBase) ConcurrentLimit ¶
func (r *MenuBase) ConcurrentLimit(limit int32)
ConcurrentLimit sets the maximum number of concurrent executions of this node and it's children.
func (MenuBase[W, D]) Dependency ¶
func (b MenuBase[W, D]) Dependency() D
type MenuCounter ¶
type PipelineAction ¶
type PipelineAction[D IPipelineCookware[M], M IPipelineModel, I any, O any] struct { Dish[D, *PipelineActionInput[M, I], *PipelineActionOutput[M, O]] // contains filtered or unexported fields }
A PipelineAction is a super set of Dish specific for managing workflow of stateful data model.
func (*PipelineAction) AfterCook ¶
func (r *PipelineAction) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec registers a handler to be called after the dish has been executed.
func (*PipelineAction) AfterCookAsync ¶
func (r *PipelineAction) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync registers a handler to be called after the dish has been executed asynchronously.
func (*PipelineAction) AfterExec ¶
func (r *PipelineAction) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec aliases of AfterCook
func (*PipelineAction) AfterExecAsync ¶
func (r *PipelineAction) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync aliases of AfterCookAsync
func (*PipelineAction) ConcurrentLimit ¶
func (r *PipelineAction) ConcurrentLimit(limit int32)
ConcurrentLimit sets the maximum number of concurrent executions of this node and it's children.
func (*PipelineAction[D, M, I, O]) CreateModel ¶
func (p *PipelineAction[D, M, I, O]) CreateModel() *PipelineAction[D, M, I, O]
func (*PipelineAction[D, M, I, O]) ExecById ¶
func (p *PipelineAction[D, M, I, O]) ExecById(ctx context.Context, input I, modelId ...any) (output O, err error)
ExecById executes the action with the input and model id.
func (*PipelineAction[D, M, I, O]) ExecByIdAndDep ¶
func (p *PipelineAction[D, M, I, O]) ExecByIdAndDep(ctx context.Context, dep D, input I, modelId ...any) (output O, err error)
ExecByIdAndDep executes the action with the dependencies and model id.
func (*PipelineAction[D, M, I, O]) ExecByIdAny ¶
func (p *PipelineAction[D, M, I, O]) ExecByIdAny(ctx context.Context, input any, ids ...any) (output any, err error)
ExecByIdAny executes the action with the input and model id.
func (*PipelineAction[D, M, I, O]) ExecWithModel ¶
func (p *PipelineAction[D, M, I, O]) ExecWithModel(ctx context.Context, model M, input I) (output O, err error)
ExecWithModel executes the action with the model and input.
func (*PipelineAction[D, M, I, O]) ExecWithModelAndDep ¶
func (p *PipelineAction[D, M, I, O]) ExecWithModelAndDep(ctx context.Context, dep D, model M, input I) (output O, err error)
ExecWithModelAndDep executes the action with the model, input and dependencies.
func (PipelineAction[D, M, I, O]) ModelToMap ¶
func (p PipelineAction[D, M, I, O]) ModelToMap(model IPipelineModel) map[string]string
ModelToMap converts the model to map for logging.
func (PipelineAction) Nodes ¶
func (b PipelineAction) Nodes() []IInstance
Nodes returns the children of this node.
func (PipelineAction[D, M, I, O]) Pipeline ¶
func (p PipelineAction[D, M, I, O]) Pipeline() IPipeline
func (*PipelineAction[D, M, I, O]) SetCooker ¶
func (p *PipelineAction[D, M, I, O]) SetCooker(cooker PipelineDishCooker[D, M, I, O]) *PipelineAction[D, M, I, O]
SetCooker sets the cooker for the action, will transform to func(i IContext[D], p *PipelineActionInput[M, I]) (output *PipelineActionOutput[M, O], err error).
func (*PipelineAction[D, M, I, O]) SetNextStage ¶
func (p *PipelineAction[D, M, I, O]) SetNextStage(stage IPipelineStage) *PipelineAction[D, M, I, O]
SetNextStage sets the next stage for the action.
func (PipelineAction[D, M, I, O]) Status ¶
func (p PipelineAction[D, M, I, O]) Status() PipelineStatus
func (*PipelineAction[D, M, I, O]) WillCreateModel ¶
func (p *PipelineAction[D, M, I, O]) WillCreateModel() bool
WillCreateModel returns true if the action will create a model, can input nil in Cook.
type PipelineActionInput ¶
type PipelineActionInput[M IPipelineModel, I any] struct { Input I Model M Before map[string]string Status PipelineStatus }
func PipelineActionInputToAny ¶
func PipelineActionInputToAny[M IPipelineModel](input any) PipelineActionInput[M, any]
PipelineActionInputToAny transforms the input to PipelineActionInput.
type PipelineActionOutput ¶
type PipelineActionOutput[M IPipelineModel, O any] struct { Output O Model M }
func PipelineActionOutputToAny ¶
func PipelineActionOutputToAny[M IPipelineModel](output any) PipelineActionOutput[M, any]
PipelineActionOutputToAny transforms the output to PipelineActionOutput.
type PipelineBase ¶
type PipelineBase[P iPipeline[D, M], D IPipelineCookware[M], M IPipelineModel] struct {
MenuBase[P, D]
StageByStatus map[string]iPipelineStage[D, M]
}
PipelineBase is a super set of MenuBase, should embed to all pipelines.
func (*PipelineBase) AfterCook ¶
func (r *PipelineBase) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec registers a handler to be called after the dish has been executed.
func (*PipelineBase) AfterCookAsync ¶
func (r *PipelineBase) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync registers a handler to be called after the dish has been executed asynchronously.
func (*PipelineBase) AfterExec ¶
func (r *PipelineBase) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec aliases of AfterCook
func (*PipelineBase) AfterExecAsync ¶
func (r *PipelineBase) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync aliases of AfterCookAsync
func (*PipelineBase) ConcurrentLimit ¶
func (r *PipelineBase) ConcurrentLimit(limit int32)
ConcurrentLimit sets the maximum number of concurrent executions of this node and it's children.
func (*PipelineBase[P, D, M]) GetActionsForModel ¶
func (p *PipelineBase[P, D, M]) GetActionsForModel(model any) (string, []IPipelineAction)
GetActionsForModel returns the actions available for the model.
func (*PipelineBase[P, D, M]) GetActionsForStatus ¶
func (p *PipelineBase[P, D, M]) GetActionsForStatus(status string) []IPipelineAction
GetActionsForStatus returns the actions available for the status.
func (PipelineBase[P, D, M]) NewModel ¶
func (p PipelineBase[P, D, M]) NewModel() IPipelineModel
type PipelineContext ¶
type PipelineContext[D IPipelineCookware[M], M IPipelineModel] struct {
Context[D]
// contains filtered or unexported fields
}
func (PipelineContext[D, M]) Pipeline ¶
func (b PipelineContext[D, M]) Pipeline() iPipeline[D, M]
func (PipelineContext[D, M]) Stage ¶
func (b PipelineContext[D, M]) Stage() iPipelineStage[D, M]
func (PipelineContext[D, M]) Tx ¶
func (b PipelineContext[D, M]) Tx() IDbTx
type PipelineContextForTest ¶
type PipelineContextForTest[D IPipelineCookware[M], M IPipelineModel] struct {
ContextForTest[D]
DummyTx IDbTx
}
func (PipelineContextForTest[D, M]) Pipeline ¶
func (b PipelineContextForTest[D, M]) Pipeline() iPipeline[D, M]
func (PipelineContextForTest[D, M]) Stage ¶
func (b PipelineContextForTest[D, M]) Stage() iPipelineStage[D, M]
func (PipelineContextForTest[D, M]) Tx ¶
func (b PipelineContextForTest[D, M]) Tx() IDbTx
type PipelineDishCooker ¶
type PipelineStage ¶
type PipelineStage[D IPipelineCookware[M], M IPipelineModel] struct {
SetBase[D]
// contains filtered or unexported fields
}
PipelineStage is a super set of SetBase, should embed to all pipeline stages. example: a order model can have stages like "ordered", "wait for payment", "pending delivery", "delivery", "complete".
func (PipelineStage[D, M]) Actions ¶
func (ps PipelineStage[D, M]) Actions() []IPipelineAction
Actions returns the actions available for the stage.
func (*PipelineStage) AfterCook ¶
func (r *PipelineStage) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec registers a handler to be called after the dish has been executed.
func (*PipelineStage) AfterCookAsync ¶
func (r *PipelineStage) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync registers a handler to be called after the dish has been executed asynchronously.
func (*PipelineStage) AfterExec ¶
func (r *PipelineStage) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec aliases of AfterCook
func (*PipelineStage) AfterExecAsync ¶
func (r *PipelineStage) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync aliases of AfterCookAsync
func (*PipelineStage) ConcurrentLimit ¶
func (r *PipelineStage) ConcurrentLimit(limit int32)
ConcurrentLimit sets the maximum number of concurrent executions of this node and it's children.
func (PipelineStage) Nodes ¶
func (b PipelineStage) Nodes() []IInstance
Nodes returns the children of this node.
func (PipelineStage[D, M]) Status ¶
func (ps PipelineStage[D, M]) Status() PipelineStatus
type PipelineStatus ¶
type PipelineStatus string
type SetBase ¶
type SetBase[D ICookware] struct {
// contains filtered or unexported fields
}
SetBase is a struct for supporting ISet, can treat as a sub menu.
func (*SetBase) AfterCook ¶
func (r *SetBase) AfterCook(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec registers a handler to be called after the dish has been executed.
func (*SetBase) AfterCookAsync ¶
func (r *SetBase) AfterCookAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync registers a handler to be called after the dish has been executed asynchronously.
func (*SetBase) AfterExec ¶
func (r *SetBase) AfterExec(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExec aliases of AfterCook
func (*SetBase) AfterExecAsync ¶
func (r *SetBase) AfterExecAsync(handler AfterListenHandlers[D, I, O], toLog ...any) *cookbook[D, I, O]
AfterExecAsync aliases of AfterCookAsync
func (*SetBase) ConcurrentLimit ¶
func (r *SetBase) ConcurrentLimit(limit int32)
ConcurrentLimit sets the maximum number of concurrent executions of this node and it's children.
func (SetBase) Nodes ¶
func (b SetBase) Nodes() []IInstance
Nodes returns the children of this node.
func (*SetBase[D]) OverridePath ¶
type ZeroLogTraceableCookware ¶
func NewZeroLogTraceableCookware ¶
func NewZeroLogTraceableCookware[D ICookware](l *zerolog.Logger) *ZeroLogTraceableCookware[D]
func (ZeroLogTraceableCookware[D]) StartTrace ¶
func (d ZeroLogTraceableCookware[D]) StartTrace(ctx IContext[D], id string, input any) (context.Context, iTraceSpan[D])
