Documentation ¶
Index ¶
- type AzureFunction
- func InheritAzureFunction(overrides IAzureFunctionOverrides) *AzureFunction
- func InheritAzureFunctionWithParams(overrides IAzureFunctionOverrides, name string, description string) *AzureFunction
- func NewAzureFunction() *AzureFunction
- func NewAzureFunctionWithParams(name string, description string) *AzureFunction
- func (c *AzureFunction) Execute(res http.ResponseWriter, req *http.Request)
- func (c *AzureFunction) GetCommand(r *http.Request) (string, error)
- func (c *AzureFunction) GetHandler() http.HandlerFunc
- func (c *AzureFunction) GetTraceId(r *http.Request) string
- func (c *AzureFunction) Instrument(ctx context.Context, name string) *rpctrace.InstrumentTiming
- func (c *AzureFunction) Open(ctx context.Context) error
- func (c *AzureFunction) Register()
- func (c *AzureFunction) RegisterAction(cmd string, schema *cvalid.Schema, action http.HandlerFunc)deprecated
- func (c *AzureFunction) RegisterControllers()
- func (c *AzureFunction) Run(ctx context.Context)
- func (c *AzureFunction) SetConfigPath(configPath string)
- func (c *AzureFunction) SetReferences(ctx context.Context, references crefer.IReferences)
- type CommandableAzureFunctiondeprecated
- type IAzureFunctionOverrides
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AzureFunction ¶
type AzureFunction struct { *ccont.Container Overrides IAzureFunctionOverrides // The dependency resolver. DependencyResolver *crefer.DependencyResolver // The performanc counters. Counters *ccount.CompositeCounters // The tracer. Tracer *ctrace.CompositeTracer // The map of registred validation schemas. Schemas map[string]*cvalid.Schema // The map of registered actions. Actions map[string]http.HandlerFunc // contains filtered or unexported fields }
Abstract Azure Function, that acts as a container to instantiate and run components and expose them via external entry point.
When handling calls "cmd" parameter determines which what action shall be called, while other parameters are passed to the action itself.
Container configuration for this Azure Function is stored in "./config/config.yml" file. But this path can be overriden by CONFIG_PATH environment variable.
References - *:logger:*:*:1.0 (optional) ILogger components to pass log messages - *:counters:*:*:1.0 (optional) ICounters components to pass collected measurements - *:controller:azurefunc:*:1.0 (optional) IAzureFunctionController controllers to handle action requests - *:controller:commandable-azurefunc:*:1.0 (optional) IAzureFunctionController controllers to handle action requests Example: type MyAzureFunction struct { *containers.AzureFunction } func NewMyAzureFunction() *MyAzureFunction { c := MyAzureFunction{} c.AzureFunction = containers.NewAzureFunctionWithParams("mygroup", "MyGroup Azure Function") return &c } ... AzureFunction := NewMyAzureFunction() AzureFunction.Run(ctx) fmt.Println("MyAzureFunction is started")
func InheritAzureFunction ¶
func InheritAzureFunction(overrides IAzureFunctionOverrides) *AzureFunction
InheritAzureFunction creates new instance of AzureFunction
func InheritAzureFunctionWithParams ¶
func InheritAzureFunctionWithParams(overrides IAzureFunctionOverrides, name string, description string) *AzureFunction
InheritAzureFunction creates new instance of AzureFunction Parameters:
- name (optional) a container name (accessible via ContextInfo)
- description (optional) a container description (accessible via ContextInfo)
func NewAzureFunction ¶
func NewAzureFunction() *AzureFunction
Creates a new instance of this Azure Function function.
func NewAzureFunctionWithParams ¶
func NewAzureFunctionWithParams(name string, description string) *AzureFunction
Creates a new instance of this Azure Function function. Parameters:
- name (optional) a container name (accessible via ContextInfo)
- description (optional) a container description (accessible via ContextInfo)
func (*AzureFunction) Execute ¶
func (c *AzureFunction) Execute(res http.ResponseWriter, req *http.Request)
Executes this Azure Function and returns the result. This method can be overloaded in child classes if they need to change the default behavior
Parameters: - res the function response - req the function request
func (*AzureFunction) GetCommand ¶
func (c *AzureFunction) GetCommand(r *http.Request) (string, error)
Returns command from Azure Function request. This method can be overloaded in child classes
Parameters: - req Function request
Returns command from request
func (*AzureFunction) GetHandler ¶
func (c *AzureFunction) GetHandler() http.HandlerFunc
Gets entry point into this Azure Function.
Parameters: - res the function response - req the function request
func (*AzureFunction) GetTraceId ¶
func (c *AzureFunction) GetTraceId(r *http.Request) string
Returns traceId from Googel Function request. This method can be overloaded in child classes
Parameters: - req Function request
Returns traceId from request
func (*AzureFunction) Instrument ¶
func (c *AzureFunction) Instrument(ctx context.Context, name string) *rpctrace.InstrumentTiming
Instrument method are adds instrumentation to log calls and measure call time. It returns a Timing object that is used to end the time measurement.
Parameters: - ctx context.Context transaction id to trace execution through call chain. - name a method name. Returns: Timing object to end the time measurement.
func (*AzureFunction) Open ¶
func (c *AzureFunction) Open(ctx context.Context) error
Open opens the component.
Parameters: - ctx context.Context transaction id to trace execution through call chain. Return: error
func (*AzureFunction) Register ¶
func (c *AzureFunction) Register()
func (*AzureFunction) RegisterAction
deprecated
func (c *AzureFunction) RegisterAction(cmd string, schema *cvalid.Schema, action http.HandlerFunc)
Registers an action in this Azure Function.
Parameters: - cmd a action/command name. - schema a validation schema to validate received parameters. - action an action function that is called when action is invoked.
Deprecated: This method has been deprecated. Use AzureFunctionService instead.
func (*AzureFunction) RegisterControllers ¶
func (c *AzureFunction) RegisterControllers()
Registers all Azure Function services in the container.
func (*AzureFunction) Run ¶
func (c *AzureFunction) Run(ctx context.Context)
Runs this Azure Function, loads container configuration, instantiate components and manage their lifecycle, makes this function ready to access action calls.
Parameters: - ctx context.Context
func (*AzureFunction) SetConfigPath ¶
func (c *AzureFunction) SetConfigPath(configPath string)
SetConfigPath set path for configuration file Parameters:
- configPath path to config file
func (*AzureFunction) SetReferences ¶
func (c *AzureFunction) SetReferences(ctx context.Context, references crefer.IReferences)
SetReferences sets references to dependent components.
see IReferences Parameters: - ctx context.Context - references IReferences references to locate the component dependencies.
type CommandableAzureFunction
deprecated
type CommandableAzureFunction struct {
*AzureFunction
}
Abstract Azure Function function, that acts as a container to instantiate and run components and expose them via external entry point. All actions are automatically generated for commands defined in ICommandable components. Each command is exposed as an action defined by "cmd" parameter.
Container configuration for this Azure Function is stored in "./config/config.yml" file. But this path can be overridden by <code>CONFIG_PATH</code> environment variable.
References - *:logger:*:*:1.0 (optional) ILogger components to pass log messages - *:counters:*:*:1.0 (optional) ICounters components to pass collected measurements - *:controller:azurefunc:*:1.0 (optional) IAzureFunctionController controllers to handle action requests - *:controller:commandable-azurefunc:*:1.0 (optional) IAzureFunctionController controllers to handle action requests Example: type MyAzureFunction struct { *containers.CommandableAzureFunction controller IMyController } func NewMyAzureFunction() *MyAzureFunction { c := MyAzureFunction{} c.AzureFunction = containers.NewCommandableAzureFunctionWithParams("mygroup", "MyGroup AzureFunction") return &c } ... AzureFunction := NewMyAzureFunction() AzureFunction.Run(ctx) fmt.Println("MyAzureFunction is started")
Deprecated: This component has been deprecated. Use AzureFunctionService instead.
func NewCommandableAzureFunction ¶
func NewCommandableAzureFunction() *CommandableAzureFunction
Creates a new instance of this Azure Function.
func NewCommandableAzureFunctionWithParams ¶
func NewCommandableAzureFunctionWithParams(name string, description string) *CommandableAzureFunction
Creates a new instance of this Azure Function. Parameters:
- name (optional) a container name (accessible via ContextInfo)
- description (optional) a container description (accessible via ContextInfo)
func (*CommandableAzureFunction) GetParameters ¶
func (c *CommandableAzureFunction) GetParameters(req *http.Request) *cexec.Parameters
Returns body from Azure Function request. This method can be overloaded in child classes Parameters:
- req Googl Function request
Returns Parameters from request
func (*CommandableAzureFunction) Register
deprecated
func (c *CommandableAzureFunction) Register()
Registers all actions in this Azure Function.
Deprecated: Overloading of this method has been deprecated. Use AzureFunctionService instead.
type IAzureFunctionOverrides ¶
type IAzureFunctionOverrides interface { crefer.IReferenceable // Registers all actions in this Azure Function. // // Depecated: Overloading of this method has been deprecated. Use AzureFunctionService instead. Register() }