flow

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MODULE_HEALTHCHECK = "健康检查"
	MODULE_HANDLER     = "执行节点"
	MODULE_DEBUG       = "调试"
)

Variables

View Source
var Cfg = new(Config)

Cfg 全局配置(需要先执行MustLoad,否则拿不到配置)

Functions

func GetGrpcContext

func GetGrpcContext(ctx context.Context, name string, mode TaskMode) context.Context

func Init

func Init()

Types

type App

type App interface {
	Start(flow Flow)
}

func NewApp

func NewApp() App

NewApp 创建App

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) DebugStream

func (c *Client) DebugStream(ctx context.Context) error

func (*Client) Handler

func (c *Client) Handler(ctx context.Context) error

func (*Client) Start

func (c *Client) Start(app App, flow Flow) *Client

func (*Client) Stop

func (c *Client) Stop()

type Config

type Config struct {
	Flow struct {
		Name    string   `json:"name" yaml:"name"`
		Mode    TaskMode `json:"mode" yaml:"mode"`
		Timeout uint     `json:"timeout" yaml:"timeout"`
	} `json:"flow" yaml:"flow"`
	FlowEngine Grpc          `json:"flowEngine" yaml:"flowEngine"`
	Log        logger.Config `json:"log" yaml:"log"`
	Pprof      struct {
		Enable bool   `json:"enable" yaml:"enable"`
		Host   string `json:"host" yaml:"host"`
		Port   string `json:"port" yaml:"port"`
	} `json:"pprof" yaml:"pprof"`
	EtcdConfig string           `json:"etcdConfig" yaml:"etcdConfig"`
	Etcd       etcd.Config      `json:"etcd" yaml:"etcd"`
	API        apiConfig.Config `json:"api" yaml:"api"`
}

type DebugRequest

type DebugRequest struct {
	ProjectId string `json:"projectId,omitempty"`
	FlowId    string `json:"flowId,omitempty"`
	ElementId string `json:"elementId,omitempty"`
	Config    []byte `json:"config,omitempty"`
}

type DebugResult

type DebugResult struct {
	Logs  []Syslog               `json:"logs"`
	Value map[string]interface{} `json:"value"`
}

type Flow

type Flow interface {
	// Handler
	// @description 执行流程插件
	// @param request 执行参数 {"projectId":"项目id","flowId":"流程id","job":"流程实例id","elementId":"节点id","elementJob":"节点的实例id","config":{}} config 节点配置
	// @return result "自定义返回的格式或者空"
	Handler(ctx context.Context, app App, request *Request) (result map[string]interface{}, err error)
	Debug(ctx context.Context, app App, request *DebugRequest) (result *DebugResult, err error)
}

type Grpc

type Grpc struct {
	Host  string `json:"host" yaml:"host"`
	Port  int    `json:"port" yaml:"port"`
	Limit int    `json:"limit" yaml:"limit"`
}

type Request

type Request struct {
	ProjectId  string `json:"projectId,omitempty"`
	FlowId     string `json:"flowId,omitempty"`
	Job        string `json:"job,omitempty"`
	ElementId  string `json:"elementId,omitempty"`
	ElementJob string `json:"elementJob,omitempty"`
	Config     []byte `json:"config,omitempty"`
}

type Syslog

type Syslog struct {
	Level string `json:"level"`
	Time  string `json:"time"`
	Msg   string `json:"msg"`
}

type TaskMode

type TaskMode string
const (
	UserTask    TaskMode = "user"
	ServiceTask TaskMode = "service"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL