Documentation ¶
Overview ¶
Package resource interfaces retrieval of bytecode, output templates and external code execution.
Index ¶
- type CodeFunc
- type DbResource
- func (g *DbResource) Close() error
- func (g *DbResource) DbFuncFor(ctx context.Context, sym string) (EntryFunc, error)
- func (g *DbResource) DbGetCode(ctx context.Context, sym string) ([]byte, error)
- func (g *DbResource) DbGetMenu(ctx context.Context, sym string) (string, error)
- func (g *DbResource) DbGetTemplate(ctx context.Context, sym string) (string, error)
- func (g *DbResource) With(typ uint8) *DbResource
- func (g *DbResource) WithOnly(typ uint8) *DbResource
- func (g *DbResource) Without(typ uint8) *DbResource
- type EntryFunc
- type FuncForFunc
- type MenuFunc
- type MenuResource
- func (m *MenuResource) AddLocalFunc(sym string, fn EntryFunc)
- func (m *MenuResource) Close() error
- func (m *MenuResource) FallbackFunc(ctx context.Context, sym string) (EntryFunc, error)
- func (m *MenuResource) FuncFor(ctx context.Context, sym string) (EntryFunc, error)
- func (m *MenuResource) GetCode(ctx context.Context, sym string) ([]byte, error)
- func (m *MenuResource) GetMenu(ctx context.Context, sym string) (string, error)
- func (m *MenuResource) GetTemplate(ctx context.Context, sym string) (string, error)
- func (m *MenuResource) WithCodeGetter(codeGetter CodeFunc) *MenuResource
- func (m *MenuResource) WithEntryFuncGetter(entryFuncGetter FuncForFunc) *MenuResource
- func (m *MenuResource) WithMenuGetter(menuGetter MenuFunc) *MenuResource
- func (m *MenuResource) WithTemplateGetter(templateGetter TemplateFunc) *MenuResource
- type Resource
- type Result
- type TemplateFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeFunc ¶
CodeFunc is the function signature for retrieving bytecode for a given symbol.
type DbResource ¶
type DbResource struct { *MenuResource // contains filtered or unexported fields }
DbResource is a MenuResource that uses the given db.Db implementation as data retriever.
It implements the Resource interface.
The DbResource can resolve any db.DATATYPE_* if instructed to do so.
func NewDbResource ¶
func NewDbResource(store db.Db) *DbResource
NewDbResource instantiates a new DbResource
By default it will handle db.DATATYPE_TEPMLATE, db.DATATYPE_MENU and db.DATATYPE_BIN.
func (*DbResource) Close ¶
func (g *DbResource) Close() error
Close implements the Resource interface.
func (*DbResource) DbFuncFor ¶
The method will first attempt to resolve using the function registered with the MenuResource parent class.
If no match is found, and if support for db.DATATYPE_STATICLOAD has been enabled, an additional lookup will be performed using the underlying db.
By default bound to FuncFor. Can be replaced with WithEntryFuncGetter.
func (*DbResource) DbGetCode ¶
Will fail if support for db.DATATYPE_BIN has been disabled.
By default bound to GetCode. Can be replaced with WithCodeGetter.
func (*DbResource) DbGetMenu ¶
Will fail if support for db.DATATYPE_MENU has been disabled.
By default bound to GetMenu. Can be replaced with WithMenuGetter.
func (*DbResource) DbGetTemplate ¶
Will fail if support for db.DATATYPE_TEMPLATE has been disabled.
By default bound to GetTemplate. Can be replaced with WithTemplateGetter.
func (*DbResource) With ¶
func (g *DbResource) With(typ uint8) *DbResource
Without is a chainable function that enables handling of the given data type.
func (*DbResource) WithOnly ¶
func (g *DbResource) WithOnly(typ uint8) *DbResource
WithOnly is a chainable convenience function that disables handling of all except the given data type.
func (*DbResource) Without ¶
func (g *DbResource) Without(typ uint8) *DbResource
Without is a chainable function that disables handling of the given data type.
type EntryFunc ¶
EntryFunc is a function signature for a function that resolves the symbol of a LOAD instruction.
The EntryFunc receives the current input buffer from the client, aswell as the symbol of the current state node being executed.
The implementer MUST NOT modify state flags or cache inside the function. The resource.Result object MUST be used instead.
type FuncForFunc ¶
FuncForFunc is a function that returns an EntryFunc associated with a LOAD instruction symbol.
type MenuFunc ¶
MenuFunc is the function signature for retrieving menu symbol resolution.
type MenuResource ¶
type MenuResource struct {
// contains filtered or unexported fields
}
MenuResource contains the base definition for building Resource implementations.
func NewMenuResource ¶
func NewMenuResource() *MenuResource
NewMenuResource creates a new MenuResource instance.
func (*MenuResource) AddLocalFunc ¶
func (m *MenuResource) AddLocalFunc(sym string, fn EntryFunc)
AddLocalFunc associates a handler function with a external function symbol to be returned by FallbackFunc.
func (*MenuResource) Close ¶
func (m *MenuResource) Close() error
Close implements the Resource interface.
func (*MenuResource) FallbackFunc ¶
FallbackFunc returns the default handler function for a given external function symbol.
func (*MenuResource) FuncFor ¶
FuncFor implements Resource interface.
func (*MenuResource) GetCode ¶
GetCode implements Resource interface.
func (*MenuResource) GetMenu ¶
GetMenu implements Resource interface.
func (*MenuResource) GetTemplate ¶
GetTemplate implements Resource interface.
func (*MenuResource) WithCodeGetter ¶
func (m *MenuResource) WithCodeGetter(codeGetter CodeFunc) *MenuResource
WithCodeGetter sets the code symbol resolver method.
func (*MenuResource) WithEntryFuncGetter ¶
func (m *MenuResource) WithEntryFuncGetter(entryFuncGetter FuncForFunc) *MenuResource
WithEntryGetter sets the content symbol resolver getter method.
func (*MenuResource) WithMenuGetter ¶
func (m *MenuResource) WithMenuGetter(menuGetter MenuFunc) *MenuResource
WithMenuGetter sets the menu symbol resolver method.
func (*MenuResource) WithTemplateGetter ¶
func (m *MenuResource) WithTemplateGetter(templateGetter TemplateFunc) *MenuResource
WithTemplateGetter sets the template symbol resolver method.
type Resource ¶
type Resource interface { // GetTemplate retrieves a render template associated with the given symbol. GetTemplate(ctx context.Context, nodeSym string) (string, error) // GetCode retrieves the bytecode associated with the given symbol. GetCode(ctx context.Context, nodeSym string) ([]byte, error) // GetMenu retrieves the menu label associated with the given symbol. GetMenu(ctx context.Context, menuSym string) (string, error) // FuncFor retrieves the external function (EntryFunc) associated with the given symbol. FuncFor(ctx context.Context, loadSym string) (EntryFunc, error) // Close implements the io.Closer interface. // // Safely shuts down retrieval backend. Close() error }
Resource implementation are responsible for retrieving values and templates for symbols, and can render templates from value dictionaries.
All methods must fail if the symbol cannot be resolved.
type Result ¶
type Result struct { // content value for symbol after execution. Content string // application defined status code which can complement error returns Status int // request caller to set error flags at given indices. FlagSet []uint32 // request caller to reset error flags at given indices. FlagReset []uint32 }
Result contains the results of an external code operation.