Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kouzant/execloop
Simple task execution control loop
https://github.com/kouzant/execloop
control-systems execution golang golang-library
Last synced: 22 days ago
JSON representation
Simple task execution control loop
- Host: GitHub
- URL: https://github.com/kouzant/execloop
- Owner: kouzant
- License: gpl-3.0
- Created: 2020-02-09T14:37:05.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-16T17:05:01.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T16:48:20.509Z (6 months ago)
- Topics: control-systems, execution, golang, golang-library
- Language: Go
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# execloop
Simple task execution engine.
## Installation
To install `execloop` simply run `go get -u github.com/kouzant/execloop`
## Usage
`execloop` is a very simple and generic execution engine with retryable tasks.
In the very basics it's an oversimplified control loop constantly trying to reach
a final state by executing a `Plan` consisting of some `Tasks`.### Task
A `Task` is an isolated unit of work. A Task can have sub-tasks which will be
executed after the parent task has finished successfully. The main workload is
executed in the `PerformAction` function surrounded by a `Pre` and `Post`
action.Your `Task` implementation should comply with the following interface:
```go
type Task interface {
Pre() error
PerformAction() ([]Task, error)
Post() error
Name() string
}
```### Plan
One or more `Tasks` form a `Plan` and this is what is going to be executed
by the scheduler. In every loop, the plan will be asked to return a set of
tasks to be executed in order to reach a final state. **Only** when the plan
will return an **empty** set of tasks the execution will stop.Each time the scheduler will invoke the `Create` function of a plan to get
a set of tasks to execute. Eventually the `Create` function should return an
empy slice of `Tasks` meaning the final state has been reached.A `Plan` should implement the follwing interface:
```go
type Plan interface {
Create() ([]Task, error)
}
```### Executor
Finally a plan will be executed by the scheduler. You can invoke the `Run(plan Plan) error`
or the `RunWithContext(ctx context.Context, plan Plan) error` function to
execute a plan. The latter will timeout after a configurable period of time.Call `executor.New(options *execloop.Options) *Executor` to create a new
scheduler. The `Options` are the following:```go
type Options struct {
Logger Logger
SleepBetweenRuns time.Duration
ErrorsToTolerate int
ExecutionTimeout time.Duration
}
```Use the `With*` functions to override the default options obtained by `execloop.DefaultOptions()`
## Development
`make` to build and test
`make test` to run the tests
`test-no-cache` to run all tests with no cache
`make build` to build the library