VIOLIN worker pool / connection pool, rich APIs and configuration options are provided.
go get github.com/B1NARY-GR0UP/violin
package main
import (
"fmt"
"github.com/B1NARY-GR0UP/violin"
)
func main() {
v := violin.New()
defer v.Shutdown()
v.Submit(func() {
fmt.Println("Hello, VIOLIN!")
})
}
package main
import (
"net"
"time"
"github.com/B1NARY-GR0UP/violin/cool"
)
func main() {
producer := func() (net.Conn, error) {
return net.Dial("your-network", "your-address")
}
c, _ := cool.New(5, 30, producer, cool.WithConnIdleTimeout(30*time.Second))
defer c.Close()
_ = c.Len()
conn, _ := c.Get()
_ = conn.Close()
if cc, ok := conn.(*cool.Conn); ok {
cc.MarkUnusable()
if cc.IsUnusable() {
_ = cc.Close()
}
}
}
Option | Default | Description |
---|---|---|
WithMinWorkers |
0 |
Set the minimum number of workers |
WithMaxWorkers |
5 |
Set the maximum number of workers |
WithWorkerIdleTimeout |
3 * time.Second |
Set the destroyed timeout of idle workers |
Option | Default | Description |
---|---|---|
WithConnIdleTimeout |
0 |
Set the connection idle timeout |
Sincere appreciation to the following repositories that made the development of VIOLIN possible.
VIOLIN is distributed under the Apache License 2.0. The licenses of third party dependencies of VIOLIN are explained here.
VIOLIN is a Subproject of the Basic Middleware Service