kis-flow/kis/flow.go

60 lines
2.8 KiB
Go
Raw Permalink Normal View History

2024-01-01 17:49:27 +08:00
package kis
import (
"context"
2024-04-16 14:58:00 +08:00
"time"
2024-03-26 14:54:50 +08:00
"github.com/aceld/kis-flow/common"
"github.com/aceld/kis-flow/config"
2024-01-01 17:49:27 +08:00
)
type Flow interface {
2024-04-15 17:50:02 +08:00
// Run schedules the Flow, sequentially dispatching and executing Functions in the Flow
2024-01-01 17:49:27 +08:00
Run(ctx context.Context) error
2024-04-15 17:50:02 +08:00
// Link connects the Functions in the Flow according to the configuration in the config file, and the Flow's configuration will also be updated
2024-01-01 17:49:27 +08:00
Link(fConf *config.KisFuncConfig, fParams config.FParam) error
2024-04-15 17:50:02 +08:00
// AppendNewFunction appends a new Function to the Flow
2024-03-29 18:07:57 +08:00
AppendNewFunction(fConf *config.KisFuncConfig, fParams config.FParam) error
2024-04-15 17:50:02 +08:00
// CommitRow submits Flow data to the upcoming Function layer
2024-01-03 17:22:35 +08:00
CommitRow(row interface{}) error
2024-04-15 17:50:02 +08:00
// CommitRowBatch submits Flow data to the upcoming Function layer (batch submission)
2024-03-26 16:47:34 +08:00
// row: Must be a slice
CommitRowBatch(row interface{}) error
2024-04-15 17:50:02 +08:00
// Input gets the input source data of the currently executing Function in the Flow
2024-01-03 17:22:35 +08:00
Input() common.KisRowArr
2024-04-15 17:50:02 +08:00
// GetName gets the name of the Flow
2024-01-04 16:36:36 +08:00
GetName() string
2024-04-15 17:50:02 +08:00
// GetThisFunction gets the currently executing Function
2024-01-04 16:36:36 +08:00
GetThisFunction() Function
2024-04-15 17:50:02 +08:00
// GetThisFuncConf gets the configuration of the currently executing Function
2024-01-04 16:36:36 +08:00
GetThisFuncConf() *config.KisFuncConfig
2024-04-15 17:50:02 +08:00
// GetConnector gets the Connector of the currently executing Function
2024-01-09 17:30:58 +08:00
GetConnector() (Connector, error)
2024-04-15 17:50:02 +08:00
// GetConnConf gets the configuration of the Connector of the currently executing Function
2024-01-09 17:30:58 +08:00
GetConnConf() (*config.KisConnConfig, error)
2024-04-15 17:50:02 +08:00
// GetConfig gets the configuration of the current Flow
2024-01-12 17:27:43 +08:00
GetConfig() *config.KisFlowConfig
2024-04-15 17:50:02 +08:00
// GetFuncConfigByName gets the configuration of the current Flow by Function name
2024-01-12 17:27:43 +08:00
GetFuncConfigByName(funcName string) *config.KisFuncConfig
2024-04-15 17:50:02 +08:00
// Next carries the Action actions of the next layer Function that the current Flow is executing
2024-01-23 16:21:02 +08:00
Next(acts ...ActionFunc) error
2024-04-15 17:50:02 +08:00
// GetCacheData gets the cached data of the current Flow
2024-01-26 17:27:29 +08:00
GetCacheData(key string) interface{}
2024-04-15 17:50:02 +08:00
// SetCacheData sets the cached data of the current Flow
2024-01-26 17:27:29 +08:00
SetCacheData(key string, value interface{}, Exp time.Duration)
2024-04-15 17:50:02 +08:00
// GetMetaData gets the temporary data of the current Flow
2024-01-26 17:27:29 +08:00
GetMetaData(key string) interface{}
2024-04-15 17:50:02 +08:00
// SetMetaData sets the temporary data of the current Flow
2024-01-26 17:27:29 +08:00
SetMetaData(key string, value interface{})
2024-04-15 17:50:02 +08:00
// GetFuncParam gets the default parameters of the current Flow's currently executing Function, retrieving a key-value pair
2024-01-26 17:27:29 +08:00
GetFuncParam(key string) string
2024-04-15 17:50:02 +08:00
// GetFuncParamAll gets the default parameters of the current Flow's currently executing Function, retrieving all Key-Value pairs
2024-01-26 17:27:29 +08:00
GetFuncParamAll() config.FParam
2024-04-15 17:50:02 +08:00
// GetFuncParamsAllFuncs gets the FuncParams of all Functions in the Flow, retrieving all Key-Value pairs
2024-02-04 16:27:28 +08:00
GetFuncParamsAllFuncs() map[string]config.FParam
2024-04-15 17:50:02 +08:00
// Fork gets a copy of the Flow (deep copy)
2024-02-04 16:27:28 +08:00
Fork(ctx context.Context) Flow
2024-04-15 17:50:02 +08:00
// GetID gets the Id of the Flow
GetID() string
2024-01-01 17:49:27 +08:00
}