YAO based on the flow-based programming idea, YAO encapsulates a series of atomic operations into processes; these processes can be called in YAO DSL or JavaScript scripts.
According to business characteristics, YAO defines a set of YAO DSL to describe functional modules such as data structure, data flow, API interface, concurrent tasks, scheduled tasks, and Socket services. These functional modules are defined as Widgets.
When the engine starts, it is parsed into a set of API interfaces and a set of handlers according to the Widget logic. In application development, by writing a Widget DSL to describe the differences, the corresponding functional modules can be implemented, thereby improving coding efficiency.
YAO DSL and YAO Widget support the definition of extensions according to their own business characteristics, which makes it easier to build a low-code platform based on YAO that meets their own business characteristics.
App Engine Command Line Tool & Scenario-Specific process Yao App Engine
Engine core logic & general process Gou Framework
Database ORM Xun Database
Common Data Structures & Toolkits Kun
[View source code compilation document](../Expert/Source Code Compilation)
For some specific scenarios, you need to add a new process to the engine, use the gou.RegisterProcessHandler
method to register a Golang function as a process.
It is recommended to set a specific namespace to prevent conflicts, so that it can be merged with the latest YAO code at any time.
add a handler file
mkdir -p /code/root/yao/myprocessestouch /code/root/yao/myprocesses/hello.gotouch /code/root/yao/myprocesses/hello_test.go
/code/root/yao/myprocesses/hello.go
package myprocessesimport("github.com/yaoapp/gou")func init() {gou.RegisterProcessHandler("mycom.myprocesses.hello", processHello) // register the process}// processHello processing logicfunc processHello(process *gou.Process) interface{} {args := process.Argsreturn map[string]interface{}{"args": process.Args}}
referenced in the main program
Edit /code/root/yao/main.go
package mainimport ("github.com/yaoapp/yao/cmd"_ "github.com/yaoapp/gou/encoding"_ "github.com/yaoapp/yao/crypto"_ "github.com/yaoapp/yao/helper"_ "github.com/yaoapp/yao/network"_ "github.com/yaoapp/yao/system"_ "github.com/yaoapp/yao/user"_ "github.com/yaoapp/yao/xfs"_ "github.com/yaoapp/yao/myprocesses")// main programfunc main() {cmd.Execute()}
/code/root/yao/myprocesses/hello_test.go
package myprocessesimport ("testing""github.com/stretchr/testify/assert""github.com/yaoapp/gou")func TestProcessHello(t *testing.T) {args := []interface{}{"hello world", "foo", "bar", 0.618}res, err := gou.NewProcess("mycom.myprocesses.hello", args...).Exec()if err != nil {t. Fatal(err)}assert. Equal(t, []interface{}{"hello world", "foo", "bar", 0.618}, res.(map[string]interface{})["args"])}
run the test
cd /code/root/yao/myprocessesgo test -run TestProcessHello
Add dataflow file
mkdir -p /code/root/yao/tests/flows/mycomtouch /code/root/yao/tests/flows/mycom/hello.flow.json
Write logic /code/root/yao/tests/flows/mycom/hello.flow.json
{"label": "Hello","version": "1.0.0","description": "Hello","nodes": [{"name": "hello","process": "mycom.myprocesses.hello","args": ["hello world", "foo", "bar", 0.618]}],"output": "{{$res.args}}"}
run the test
cd /code/root/yao/go run . run flows.mycom.hello
add script file
mkdir -p /code/root/yao/tests/scripts/mycomtouch /code/root/yao/tests/scripts/mycom/hello.js
write script /code/root/yao/tests/scripts/mycom/hello.js
function Hi() {return Process("mycom.myprocesses.hello", "hello world", "foo", "bar", 0.618);}
run the test
cd /code/root/yao/go run . run scripts.mycom.hello.Hi
Next, it is recommended to study the following chapters:
YAO based on the flow-based programming idea, YAO encapsulates a series of atomic operations into processes; these processes can be called in YAO DSL or JavaScript scripts.
According to business characteristics, YAO defines a set of YAO DSL to describe functional modules such as data structure, data flow, API interface, concurrent tasks, scheduled tasks, and Socket services. These functional modules are defined as Widgets.
When the engine starts, it is parsed into a set of API interfaces and a set of handlers according to the Widget logic. In application development, by writing a Widget DSL to describe the differences, the corresponding functional modules can be implemented, thereby improving coding efficiency.
YAO DSL and YAO Widget support the definition of extensions according to their own business characteristics, which makes it easier to build a low-code platform based on YAO that meets their own business characteristics.
App Engine Command Line Tool & Scenario-Specific process Yao App Engine
Engine core logic & general process Gou Framework
Database ORM Xun Database
Common Data Structures & Toolkits Kun
[View source code compilation document](../Expert/Source Code Compilation)
For some specific scenarios, you need to add a new process to the engine, use the gou.RegisterProcessHandler
method to register a Golang function as a process.
It is recommended to set a specific namespace to prevent conflicts, so that it can be merged with the latest YAO code at any time.
add a handler file
mkdir -p /code/root/yao/myprocessestouch /code/root/yao/myprocesses/hello.gotouch /code/root/yao/myprocesses/hello_test.go
/code/root/yao/myprocesses/hello.go
package myprocessesimport("github.com/yaoapp/gou")func init() {gou.RegisterProcessHandler("mycom.myprocesses.hello", processHello) // register the process}// processHello processing logicfunc processHello(process *gou.Process) interface{} {args := process.Argsreturn map[string]interface{}{"args": process.Args}}
referenced in the main program
Edit /code/root/yao/main.go
package mainimport ("github.com/yaoapp/yao/cmd"_ "github.com/yaoapp/gou/encoding"_ "github.com/yaoapp/yao/crypto"_ "github.com/yaoapp/yao/helper"_ "github.com/yaoapp/yao/network"_ "github.com/yaoapp/yao/system"_ "github.com/yaoapp/yao/user"_ "github.com/yaoapp/yao/xfs"_ "github.com/yaoapp/yao/myprocesses")// main programfunc main() {cmd.Execute()}
/code/root/yao/myprocesses/hello_test.go
package myprocessesimport ("testing""github.com/stretchr/testify/assert""github.com/yaoapp/gou")func TestProcessHello(t *testing.T) {args := []interface{}{"hello world", "foo", "bar", 0.618}res, err := gou.NewProcess("mycom.myprocesses.hello", args...).Exec()if err != nil {t. Fatal(err)}assert. Equal(t, []interface{}{"hello world", "foo", "bar", 0.618}, res.(map[string]interface{})["args"])}
run the test
cd /code/root/yao/myprocessesgo test -run TestProcessHello
Add dataflow file
mkdir -p /code/root/yao/tests/flows/mycomtouch /code/root/yao/tests/flows/mycom/hello.flow.json
Write logic /code/root/yao/tests/flows/mycom/hello.flow.json
{"label": "Hello","version": "1.0.0","description": "Hello","nodes": [{"name": "hello","process": "mycom.myprocesses.hello","args": ["hello world", "foo", "bar", 0.618]}],"output": "{{$res.args}}"}
run the test
cd /code/root/yao/go run . run flows.mycom.hello
add script file
mkdir -p /code/root/yao/tests/scripts/mycomtouch /code/root/yao/tests/scripts/mycom/hello.js
write script /code/root/yao/tests/scripts/mycom/hello.js
function Hi() {return Process("mycom.myprocesses.hello", "hello world", "foo", "bar", 0.618);}
run the test
cd /code/root/yao/go run . run scripts.mycom.hello.Hi
Next, it is recommended to study the following chapters: