configure leader ws client ConnectionReadLimit

This commit is contained in:
Maxim Merzhanov committed 2020-02-26 17:48:46 +03:00
1 parent c4ded39e7c
commit 49fde946ac
3 files changed
+27 -15

No files matched your search

+3
View File
@@ -1,3 +1,6 @@
### v2.1.2
* leader ws client ConnectionReadLimit is now configured by WS.WsConnectionReadLimitKB config param and defaults to 4 MB
### v2.1.1
* update to new endpoint descriptor struct with extra fields introduced in isp-lib v2.1.0
+12 -5
View File
@@ -3,6 +3,11 @@ package cluster
import (
"context"
"fmt"
"net"
"net/http"
"net/url"
"time"
"github.com/cenkalti/backoff"
etp "github.com/integration-system/isp-etp-go/client"
"github.com/integration-system/isp-lib/config"
@@ -11,10 +16,11 @@ import (
log "github.com/integration-system/isp-log"
"isp-config-service/codes"
"isp-config-service/conf"
"net"
"net/http"
"net/url"
"time"
)
var (
// Set from config in main
WsConnectionReadLimit int64
)
type SocketLeaderClient struct {
@@ -63,7 +69,8 @@ func (c *SocketLeaderClient) Close() {
func NewSocketLeaderClient(address string, leaderDisconnectionCallback func()) *SocketLeaderClient {
etpConfig := etp.Config{
HttpClient: http.DefaultClient,
HttpClient: http.DefaultClient,
ConnectionReadLimit: WsConnectionReadLimit,
}
client := etp.NewClient(etpConfig)
leaderClient := &SocketLeaderClient{
+12 -10
View File
@@ -3,6 +3,10 @@ package main
import (
"context"
"fmt"
"net"
"net/http"
"os"
"github.com/integration-system/isp-etp-go"
"github.com/integration-system/isp-lib/backend"
"github.com/integration-system/isp-lib/bootstrap"
@@ -24,9 +28,6 @@ import (
"isp-config-service/store"
"isp-config-service/store/state"
"isp-config-service/subs"
"net"
"net/http"
"os"
)
const (
@@ -36,7 +37,6 @@ const (
var (
version = "0.1.0"
date = "undefined"
shutdownChan = make(chan struct{})
muxer mux.Mux
@@ -81,6 +81,12 @@ func main() {
Address: address,
}
connectionReadLimit := defaultWsConnectionReadLimit
if cfg.WS.WsConnectionReadLimitKB > 0 {
connectionReadLimit = cfg.WS.WsConnectionReadLimitKB << 10
}
cluster.WsConnectionReadLimit = connectionReadLimit
model.DbClient.ReceiveConfiguration(cfg.Database)
httpListener, raftListener, err := initMultiplexer(cfg.WS.Rest)
@@ -89,7 +95,7 @@ func main() {
}
_, raftStore := initRaft(raftListener, cfg.Cluster, declaration)
initWebsocket(ctx, cfg.WS.WsConnectionReadLimitKB, httpListener, raftStore)
initWebsocket(ctx, connectionReadLimit, httpListener, raftStore)
initGrpc(cfg.WS.Grpc, raftStore)
defer goodbye.Exit(ctx, -1)
@@ -121,11 +127,7 @@ func initMultiplexer(addressConfiguration structure.AddressConfiguration) (net.L
return httpListener, raftListener, nil
}
func initWebsocket(ctx context.Context, wsConnectionReadLimitKB int64, listener net.Listener, raftStore *store.Store) {
connectionReadLimit := defaultWsConnectionReadLimit
if wsConnectionReadLimitKB > 0 {
connectionReadLimit = wsConnectionReadLimitKB << 10
}
func initWebsocket(ctx context.Context, connectionReadLimit int64, listener net.Listener, raftStore *store.Store) {
etpConfig := etp.ServerConfig{
InsecureSkipVerify: true,
ConnectionReadLimit: connectionReadLimit,