Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vvatanabe/renda
Renda is a go library that repeatedly executes any processes.
https://github.com/vvatanabe/renda
Last synced: 24 days ago
JSON representation
Renda is a go library that repeatedly executes any processes.
- Host: GitHub
- URL: https://github.com/vvatanabe/renda
- Owner: vvatanabe
- License: mit
- Created: 2022-02-05T07:06:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-02-05T22:19:59.000Z (over 2 years ago)
- Last Synced: 2024-06-20T03:31:47.804Z (5 months ago)
- Language: Go
- Homepage:
- Size: 6.84 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Renda [![Go](https://github.com/vvatanabe/renda/actions/workflows/go.yml/badge.svg)](https://github.com/vvatanabe/renda/actions/workflows/go.yml)
Renda is a go library that repeatedly executes any processes.
The name "Renda" comes from the Japanese word "連打".
## Requires
- Go 1.17+
## Installation
This package can be installed with the go get command:
```
$ go get -u github.com/vvatanabe/renda
```## Usage
### Basically
```go
package mainimport (
"encoding/json"
"fmt"
"os"
"os/signal"
"time""github.com/vvatanabe/renda"
)func main() {
workers := renda.Workers(10)
maxWorkers := renda.MaxWorkers(20)hello := func() (interface{}, error) {
return "Hello 連打", nil
}
rate := &renda.Rate{Freq: 3, Per: time.Second}
duration := 5 * time.Secondr := renda.NewRenda(workers, maxWorkers)
res := r.Start(hello, rate, duration)sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt)for {
select {
case <-sig:
r.Stop()
return
case r, ok := <-res:
if !ok {
return
}
v, _ := json.Marshal(r)
fmt.Println(string(v))
}
}
}
```## Acknowledgments
[github.com/tsenart/vegeta](https://github.com/tsenart/vegeta)
## Bugs and Feedback
For bugs, questions and discussions please use the GitHub Issues.