Documentation ¶
Index ¶
- func DecodeHook(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error)
- func Register(factory IFactory) error
- type Factory
- func (f *Factory) DeepCopy() *Factory
- func (f *Factory) Identifier() string
- func (f *Factory) Input(name string) (v *Var, ok bool)
- func (f *Factory) Output(name string, value interface{}) *Factory
- func (f *Factory) Run() error
- func (f *Factory) WithConfig(config map[string]interface{}) *Factory
- func (f *Factory) WithID(id string) *Factory
- func (f *Factory) WithInput(name string, value interface{}) *Factory
- type IFactory
- type InputConfig
- type Pipeline
- func (p *Pipeline) AddFactory(f *Factory) *Pipeline
- func (p *Pipeline) CheckResult() bool
- func (p *Pipeline) DeepCopy() *Pipeline
- func (p *Pipeline) FactoryCount() int
- func (p *Pipeline) HasFactories() bool
- func (p *Pipeline) Run() *Factory
- func (p *Pipeline) WantResult(result interface{}) *Pipeline
- func (p *Pipeline) WithInput(name string, value interface{}) *Pipeline
- type RunFunc
- type Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeHook ¶
DecodeHook is a mapstructure.DecodeHook that serializes the given data into a InputConfig with a name and a Valuable object. mapstructure cannot nested objects, so we need to serialize the data into a map[string]interface{} and then deserialize it into a InputConfig.
@see https://pkg.go.dev/github.com/mitchellh/mapstructure#DecodeHookFunc for more details.
Types ¶
type Factory ¶
type Factory struct { // Name is the name of the factory function Name string // ID is the unique ID of the factory ID string // Fn is the factory function Fn RunFunc // Config is the configuration for the factory function Config map[string]interface{} // Inputs is the inputs of the factory Inputs []*Var // Outputs is the outputs of the factory Outputs []*Var // contains filtered or unexported fields }
Factory represents a factory that can be executed by the pipeline.
func GetFactoryByName ¶
GetFactoryByName returns true if the function name is contained in the map
func (*Factory) Identifier ¶
Identifier will return the id of the factory or the name of the factory if the id is not set.
func (*Factory) Input ¶
Input retrieve the input variable of the given name. @param name the name of the input variable @return the input variable of the given name @return true if the input variable was found
func (*Factory) Output ¶
Output store the output variable of the given name. @param name the name of the output variable @param value the value of the output variable @return the factory
func (*Factory) WithConfig ¶
WithConfig sets the config of the factory. @param config the config of the factory @return the factory
type IFactory ¶
type IFactory interface { // Name is the name of the factory function // The name must be unique in the registry // @return the name of the factory function Name() string // DefinedInputs returns the wanted inputs of the factory used // by the function during the execution of the pipeline DefinedInpus() []*Var // DefinedOutputs returns the wanted outputs of the factory used // by the function during the execution of the pipeline DefinedOutputs() []*Var // Func is used to build the factory function // @return the factory function Func() RunFunc }
IFactory is an interface that represents a factory.
type InputConfig ¶
InputConfig is a struct that contains the name and the value of an input. It is used to store the inputs of a factory. The name is used to retrieve the value of the input from the factory.
This is used to load the inputs of a factory from the configuration file.
type Pipeline ¶
type Pipeline struct { WantedResult interface{} LastResults []interface{} Inputs map[string]interface{} Outputs map[string]map[string]interface{} // contains filtered or unexported fields }
Pipeline is a struct that contains informations about the pipeline. It is used to store the inputs and outputs of all factories executed by the pipeline and secure the result of the pipeline.
func (*Pipeline) AddFactory ¶
AddFactory adds a new factory to the pipeline. New Factory is added to the end of the pipeline.
func (*Pipeline) CheckResult ¶
CheckResult checks if the pipeline result is the same as the wanted result. type and value of the result must be the same as the last result
func (*Pipeline) FactoryCount ¶
FactoryCount returns the number of factories in the pipeline.
func (*Pipeline) HasFactories ¶
HasFactories returns true if the pipeline has at least one factory.
func (*Pipeline) Run ¶
Run executes the pipeline. Factories are executed in the order they were added to the pipeline. The last factory is returned
@return the last factory
func (*Pipeline) WantResult ¶
WantResult sets the wanted result of the pipeline. the result is compared to the last result of the pipeline. type and value of the result must be the same as the last result
type RunFunc ¶
RunFunc is a function that is used to run a factory. It is used to run a factory in a pipeline. @param factory the factory to run @param configRaw the raw configuration of the factory
type Var ¶
type Var struct { // Internal is to specify if the variable is an internal provided variable Internal bool // Type is the type of the wanted variable Type reflect.Type // Name is the name of the variable Name string // Value is the value of the variable, type can be retrieved from Type field Value interface{} }
Var is a struct that contains the name and the value of an input or output. It is used to store the inputs and outputs of a factory.