https://github.com/coc1961/process
execute a set of steps as a process controlling the cycle and error handling
https://github.com/coc1961/process
go golang process
Last synced: 23 days ago
JSON representation
execute a set of steps as a process controlling the cycle and error handling
- Host: GitHub
- URL: https://github.com/coc1961/process
- Owner: coc1961
- Created: 2019-04-18T18:21:54.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-19T23:37:55.000Z (over 6 years ago)
- Last Synced: 2025-03-13T02:43:26.447Z (10 months ago)
- Topics: go, golang, process
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# process
> Purpose
This framework has the purpose of simplifying the execution of processes and the evaluation of errors
> Description
this framework allows to define a process as a set of steps that are executed until one of them fails. If one step fails the rest of the steps are not invoked
> Example
This Code (without using process)
```Go
func main() {
person := &Person{Name: "Name", Age: 20}
var err error
if person, err = validate(person); err != nil {
fmt.Println(err)
return
}
if person, err = create(person); err != nil {
fmt.Println(err)
return
}
if person, err = audit(person); err != nil {
fmt.Println(err)
return
}
//Ok!!
fmt.Println(person)
}
```
Can be replaced by this
```Go
func main() {
//Create Process
proc := createProcess()
//Init process
person := &Person{Name: "Name", Age: 20}
//Execute the process
//RullAll execute Validate,Create and Audit
if proc.Start(person).RunAll().Error() != nil {
//errors?
fmt.Println(proc.Error())
} else {
//Ok!!!
person := proc.Result().(*Person)
fmt.Println(person)
}
}
```