Compare commits

...
1 Commits
Author SHA1 Message Date
Maxim Merzhanov 49fde946ac configure leader ws client ConnectionReadLimit 2020-02-26 17:48:46 +03:00
3 changed files with 27 additions and 15 deletions

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