2020-01-25 00:13:14 +00:00
|
|
|
package jsonrpc
|
|
|
|
|
2020-05-01 19:30:32 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/gorilla/websocket"
|
|
|
|
)
|
2020-01-25 00:13:14 +00:00
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
ReconnectInterval time.Duration
|
2020-05-01 19:30:32 +00:00
|
|
|
|
|
|
|
proxyConnFactory func(func() (*websocket.Conn, error)) func() (*websocket.Conn, error) // for testing
|
2020-01-25 00:13:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var defaultConfig = Config{
|
|
|
|
ReconnectInterval: time.Second * 5,
|
|
|
|
}
|
|
|
|
|
|
|
|
type Option func(c *Config)
|
|
|
|
|
|
|
|
func WithReconnectInterval(d time.Duration) func(c *Config) {
|
|
|
|
return func(c *Config) {
|
|
|
|
c.ReconnectInterval = d
|
|
|
|
}
|
|
|
|
}
|