Documentation ¶
Index ¶
- type CloudFunction
- func InheritCloudFunction(overrides ICloudFunctionOverrides) *CloudFunction
- func InheritCloudFunctionWithParams(overrides ICloudFunctionOverrides, name string, description string) *CloudFunction
- func NewCloudFunction() *CloudFunction
- func NewCloudFunctionWithParams(name string, description string) *CloudFunction
- func (c *CloudFunction) Execute(res http.ResponseWriter, req *http.Request)
- func (c *CloudFunction) GetCommand(r *http.Request) (string, error)
- func (c *CloudFunction) GetCorrelationId(r *http.Request) string
- func (c *CloudFunction) GetHandler() http.HandlerFunc
- func (c *CloudFunction) Instrument(ctx context.Context, correlationId string, name string) *rpcserv.InstrumentTiming
- func (c *CloudFunction) Open(ctx context.Context, correlationId string) error
- func (c *CloudFunction) Register()
- func (c *CloudFunction) RegisterAction(cmd string, schema *cvalid.Schema, action http.HandlerFunc)deprecated
- func (c *CloudFunction) RegisterServices()
- func (c *CloudFunction) Run(ctx context.Context)
- func (c *CloudFunction) SetConfigPath(configPath string)
- func (c *CloudFunction) SetReferences(ctx context.Context, references crefer.IReferences)
- type CommandableCloudFunctiondeprecated
- type ICloudFunctionOverrides
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudFunction ¶
type CloudFunction struct { *ccont.Container Overrides ICloudFunctionOverrides // 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 Google 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 Google 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 - *:service:cloudfunc:*:1.0 (optional) ICloudFunctionService services to handle action requests - *:service:commandable-cloudfunc:*:1.0 (optional) ICloudFunctionService services to handle action requests Example: type MyCloudFunction struct { *containers.CloudFunction } func NewMyCloudFunction() *MyCloudFunction { c := MyCloudFunction{} c.CloudFunction = containers.NewCloudFunctionWithParams("mygroup", "MyGroup Google Function") return &c } ... cloudFunction := NewMyCloudFunction() cloudFunction.Run(ctx) fmt.Println("MyCloudFunction is started")
func InheritCloudFunction ¶
func InheritCloudFunction(overrides ICloudFunctionOverrides) *CloudFunction
InheritCloudFunction creates new instance of CloudFunction
func InheritCloudFunctionWithParams ¶
func InheritCloudFunctionWithParams(overrides ICloudFunctionOverrides, name string, description string) *CloudFunction
InheritCloudFunction creates new instance of CloudFunction Parameters:
- name (optional) a container name (accessible via ContextInfo)
- description (optional) a container description (accessible via ContextInfo)
func NewCloudFunction ¶
func NewCloudFunction() *CloudFunction
Creates a new instance of this Google Function function.
func NewCloudFunctionWithParams ¶
func NewCloudFunctionWithParams(name string, description string) *CloudFunction
Creates a new instance of this Google Function function. Parameters:
- name (optional) a container name (accessible via ContextInfo)
- description (optional) a container description (accessible via ContextInfo)
func (*CloudFunction) Execute ¶
func (c *CloudFunction) Execute(res http.ResponseWriter, req *http.Request)
Executes this Google 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 (*CloudFunction) GetCommand ¶
func (c *CloudFunction) GetCommand(r *http.Request) (string, error)
Returns command from Google Function request. This method can be overloaded in child classes
Parameters: - req Googel Function request
Returns command from request
func (*CloudFunction) GetCorrelationId ¶
func (c *CloudFunction) GetCorrelationId(r *http.Request) string
Returns correlationId from Googel Function request. This method can be overloaded in child classes
Parameters: - req Googel Function request
Returns correlationId from request
func (*CloudFunction) GetHandler ¶
func (c *CloudFunction) GetHandler() http.HandlerFunc
Gets entry point into this Google Function.
Parameters: - res the function response - req the function request
func (*CloudFunction) Instrument ¶
func (c *CloudFunction) Instrument(ctx context.Context, correlationId string, name string) *rpcserv.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 - correlationId (optional) transaction id to trace execution through call chain. - name a method name. Returns: Timing object to end the time measurement.
func (*CloudFunction) Open ¶
func (c *CloudFunction) Open(ctx context.Context, correlationId string) error
Open opens the component.
Parameters: - ctx context.Context - correlationId: string transaction id to trace execution through call chain. Return: error
func (*CloudFunction) Register ¶
func (c *CloudFunction) Register()
func (*CloudFunction) RegisterAction
deprecated
func (c *CloudFunction) RegisterAction(cmd string, schema *cvalid.Schema, action http.HandlerFunc)
Registers an action in this Google 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 CloudFunctionService instead.
func (*CloudFunction) RegisterServices ¶
func (c *CloudFunction) RegisterServices()
Registers all Google Function services in the container.
func (*CloudFunction) Run ¶
func (c *CloudFunction) Run(ctx context.Context)
Runs this Google Function, loads container configuration, instantiate components and manage their lifecycle, makes this function ready to access action calls.
Parameters: - ctx context.Context
func (*CloudFunction) SetConfigPath ¶
func (c *CloudFunction) SetConfigPath(configPath string)
SetConfigPath set path for configuration file Parameters:
- configPath path to config file
func (*CloudFunction) SetReferences ¶
func (c *CloudFunction) 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 CommandableCloudFunction
deprecated
type CommandableCloudFunction struct {
*CloudFunction
}
Abstract Google 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 Google 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 - *:service:cloudfunc:*:1.0 (optional) ICloudFunctionService services to handle action requests - *:service:commandable-cloudfunc:*:1.0 (optional) ICloudFunctionService services to handle action requests Example: type MyCloudFunction struct { *containers.CommandableCloudFunction controller IMyController } func NewMyCloudFunction() *MyCloudFunction { c := MyCloudFunction{} c.CloudFunction = containers.NewCommandableCloudFunctionWithParams("mygroup", "MyGroup CloudFunction") return &c } ... cloudFunction := NewMyCloudFunction() cloudFunction.Run(ctx) fmt.Println("MyCloudFunction is started")
Deprecated: This component has been deprecated. Use CloudFunctionService instead.
func NewCommandableCloudFunction ¶
func NewCommandableCloudFunction() *CommandableCloudFunction
Creates a new instance of this Google Function.
func NewCommandableCloudFunctionWithParams ¶
func NewCommandableCloudFunctionWithParams(name string, description string) *CommandableCloudFunction
Creates a new instance of this Google Function. Parameters:
- name (optional) a container name (accessible via ContextInfo)
- description (optional) a container description (accessible via ContextInfo)
func (*CommandableCloudFunction) GetParameters ¶
func (c *CommandableCloudFunction) GetParameters(req *http.Request) *crun.Parameters
Returns body from Google Function request. This method can be overloaded in child classes Parameters:
- req Googl Function request
Returns Parameters from request
func (*CommandableCloudFunction) Register
deprecated
func (c *CommandableCloudFunction) Register()
Registers all actions in this Google Function.
Deprecated: Overloading of this method has been deprecated. Use CloudFunctionService instead.
type ICloudFunctionOverrides ¶
type ICloudFunctionOverrides interface { crefer.IReferenceable // Registers all actions in this Google Function. // // Depecated: Overloading of this method has been deprecated. Use CloudFunctionService instead. Register() }