cfa

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: MIT Imports: 14 Imported by: 0

README

configurable-flow-actor

CFA is a backend logical engine to simply backend logic.

Documentation

Index

Constants

View Source
const (
	GATEWAY = "gateway"
	START   = "start"
	END     = "end"
	TASK    = "task"
)
View Source
const (
	HTTPREQUEST   = "HttpRequest"
	DATABUILDER   = "DataBuilder"
	YTBDOWNLOADER = "YtbDownloader"
)
View Source
const (
	ExprTypeHead = iota
	ExprTypeObject
	ExprTypeArray
)

Variables

This section is empty.

Functions

func CFARun

func CFARun(lg *log.Logger, flowName string, request string) ([]byte, error)

func IsArray added in v0.1.0

func IsArray(expr string) bool

func IsObject added in v0.1.0

func IsObject(expr string) bool

func IsTaskTsp added in v0.1.0

func IsTaskTsp(source string) bool

Types

type Context added in v0.1.0

type Context struct {
	Logger *log.Logger

	A *fastjson.Arena

	// flow process result
	Exit   bool
	CmdDir string
	// contains filtered or unexported fields
}

func (*Context) GetRequest added in v0.1.0

func (c *Context) GetRequest() *fastjson.Value

func (*Context) GetValue added in v0.1.0

func (c *Context) GetValue(source string) ([]*fastjson.Value, error)

func (*Context) Init added in v0.1.0

func (c *Context) Init(request string) error

func (*Context) MarshalActionRequest added in v0.1.0

func (c *Context) MarshalActionRequest(id string) string

func (*Context) MarshalActionResponse added in v0.1.0

func (c *Context) MarshalActionResponse(id string) string

func (*Context) MarshalResponse added in v0.1.0

func (c *Context) MarshalResponse() ([]byte, error)

func (*Context) NewTaskResult added in v0.1.0

func (c *Context) NewTaskResult(id string)

func (*Context) SetCmdDir added in v0.1.0

func (c *Context) SetCmdDir(dir string)

func (*Context) SetHeaders added in v0.1.0

func (c *Context) SetHeaders(id string, headers http.Header) error

func (*Context) SetResponse added in v0.1.0

func (c *Context) SetResponse(v []*fastjson.Value)

func (*Context) SetRsp added in v0.1.0

func (c *Context) SetRsp(id string, rsp []byte) error

func (*Context) SetValue added in v0.1.0

func (c *Context) SetValue(dst string, v []*fastjson.Value) error

type DataBuilder

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

func (*DataBuilder) DoTask

func (t *DataBuilder) DoTask(ctx *Context) error

type End

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

func (*End) DoTask

func (t *End) DoTask(ctx *Context) error

type Expr added in v0.1.0

type Expr struct {
	Type  int // Object Array
	Token string
	// contains filtered or unexported fields
}

func ExpressionParse added in v0.1.0

func ExpressionParse(expr string) (*Expr, error)

func (*Expr) IsActionRequest added in v0.1.0

func (e *Expr) IsActionRequest() bool

func (*Expr) IsRequest added in v0.1.0

func (e *Expr) IsRequest() bool

func (*Expr) IsResponse added in v0.1.0

func (e *Expr) IsResponse() bool

func (*Expr) IsTaskTsp added in v0.1.0

func (e *Expr) IsTaskTsp() bool

type Flow

type Flow map[string]*Node

func (*Flow) Run

func (f *Flow) Run(ctx *Context) error

type HttpRequest

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

func (*HttpRequest) DoTask

func (t *HttpRequest) DoTask(ctx *Context) error

type Node

type Node struct {
	ID      string     `json:"id"`
	Type    string     `json:"type"` // start, end, gateway, task
	Expr    string     `json:"expr"`
	Next    string     `json:"next"`
	Default string     `json:"default"`
	Task    *TaskParam `json:"task"`
}

type ParamNode

type ParamNode struct {
	Data      string            `json:"data"`
	Type      string            `json:"type"`       // string, number, bool, array
	Action    string            `json:"action"`     // data parse method, expr, data, iNfunc
	TargetIdx map[string]string `json:"target_idx"` // to replace target dst item
	SourceIdx map[string]string `json:"source_idx"` // to replace source dst item
}

type Request added in v0.1.0

type Request struct {
	Post interface{}            `json:"post"`
	Get  map[string]interface{} `json:"get"`
}

type RunNode

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

func (*RunNode) Run added in v0.1.0

func (n *RunNode) Run(ctx *Context) error

type Start

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

func (*Start) DoTask

func (t *Start) DoTask(ctx *Context) error

type Task

type Task interface {
	DoTask(ctx *Context) error
}

func NewTask

func NewTask(tp *TaskParam, taskType string) Task

type TaskParam

type TaskParam struct {
	ID          string                `json:"id"`
	TaskType    string                `json:"task_type"`
	Path        string                `json:"path"`
	Method      string                `json:"method"`
	ContentType string                `json:"content_type"`
	Request     map[string]*ParamNode `json:"request"` // 后续在更改为可以替换的
	Response    map[string]*ParamNode `json:"response"`
}

type TaskResult added in v0.1.0

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

type YtbDownloader added in v0.1.0

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

func (*YtbDownloader) DoTask added in v0.1.0

func (t *YtbDownloader) DoTask(ctx *Context) error

type YtbParams added in v0.1.0

type YtbParams struct {
	DstDir     string `json:"dst_dir"`
	IsPlayList bool   `json:"is_playlist"`
	Format     string `json:"format"`
	Url        string `json:"url"`
}

Jump to

Keyboard shortcuts

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