Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d61ec49c3 | ||
|
|
9dc598feff | ||
|
|
49fde946ac |
No files matched your search
@@ -1,3 +1,9 @@
|
||||
### v2.1.3
|
||||
* improved logging
|
||||
|
||||
### 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
|
||||
|
||||
|
||||
+41
-25
@@ -2,6 +2,9 @@ package cluster
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/integration-system/isp-lib/structure"
|
||||
"github.com/integration-system/isp-lib/utils"
|
||||
log "github.com/integration-system/isp-log"
|
||||
@@ -10,8 +13,6 @@ import (
|
||||
"isp-config-service/entity"
|
||||
"isp-config-service/raft"
|
||||
"isp-config-service/store/state"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -105,6 +106,12 @@ func (client *Client) SyncApplyOnLeader(command []byte) (*ApplyLogResponse, erro
|
||||
func (client *Client) listenLeader() {
|
||||
for n := range client.r.LeaderCh() {
|
||||
client.leaderMu.Lock()
|
||||
log.WithMetadata(map[string]interface{}{
|
||||
"leader_elected": n.LeaderElected,
|
||||
"current_leader": n.CurrentLeaderAddress,
|
||||
"is_leader": n.IsLeader,
|
||||
}).Info(codes.LeaderStateChanged, "leader state changed")
|
||||
|
||||
if client.leaderClient != nil {
|
||||
log.Debugf(0, "close previous leader ws connection %s", client.leaderState.leaderAddr)
|
||||
client.leaderClient.Close()
|
||||
@@ -120,29 +127,10 @@ func (client *Client) listenLeader() {
|
||||
}
|
||||
client.leaderClient = leaderClient
|
||||
|
||||
go func(declaration structure.BackendDeclaration) {
|
||||
response, err := leaderClient.SendDeclaration(declaration, defaultApplyTimeout)
|
||||
if err != nil {
|
||||
log.Warnf(codes.SendDeclarationToLeaderError, "send declaration to leader. err: %v", err)
|
||||
} else if response != utils.WsOkResponse {
|
||||
log.Warnf(codes.SendDeclarationToLeaderError, "send declaration to leader. response: %s", response)
|
||||
}
|
||||
}(client.declaration)
|
||||
log.Info(codes.SendDeclarationToLeader, "sending declaration to leader through websocket")
|
||||
go client.declareMyselfToLeader(leaderClient)
|
||||
} else if n.LeaderElected && n.IsLeader {
|
||||
go func(declaration structure.BackendDeclaration) {
|
||||
now := state.GenerateDate()
|
||||
module := entity.Module{
|
||||
Id: state.GenerateId(),
|
||||
Name: declaration.ModuleName,
|
||||
CreatedAt: now,
|
||||
LastConnectedAt: now,
|
||||
}
|
||||
command := PrepareModuleConnectedCommand(module)
|
||||
syncApplyCommand(client, command, "ModuleConnectedCommand")
|
||||
|
||||
declarationCommand := PrepareUpdateBackendDeclarationCommand(declaration)
|
||||
syncApplyCommand(client, declarationCommand, "UpdateBackendDeclarationCommand")
|
||||
}(client.declaration)
|
||||
go client.declareMyselfToCluster()
|
||||
}
|
||||
client.leaderState = leaderState{
|
||||
leaderElected: n.LeaderElected,
|
||||
@@ -153,6 +141,31 @@ func (client *Client) listenLeader() {
|
||||
client.leaderMu.Unlock()
|
||||
}
|
||||
}
|
||||
func (client *Client) declareMyselfToLeader(leaderClient *SocketLeaderClient) {
|
||||
response, err := leaderClient.SendDeclaration(client.declaration, defaultApplyTimeout)
|
||||
if err != nil {
|
||||
log.Warnf(codes.SendDeclarationToLeader, "send declaration to leader. err: %v", err)
|
||||
} else if response != utils.WsOkResponse {
|
||||
log.Warnf(codes.SendDeclarationToLeader, "send declaration to leader. response: %s", response)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// used when a leader need to declare himself to a cluster
|
||||
func (client *Client) declareMyselfToCluster() {
|
||||
now := state.GenerateDate()
|
||||
module := entity.Module{
|
||||
Id: state.GenerateId(),
|
||||
Name: client.declaration.ModuleName,
|
||||
CreatedAt: now,
|
||||
LastConnectedAt: now,
|
||||
}
|
||||
command := PrepareModuleConnectedCommand(module)
|
||||
syncApplyCommand(client, command, "ModuleConnectedCommand")
|
||||
|
||||
declarationCommand := PrepareUpdateBackendDeclarationCommand(client.declaration)
|
||||
syncApplyCommand(client, declarationCommand, "UpdateBackendDeclarationCommand")
|
||||
}
|
||||
|
||||
type leaderState struct {
|
||||
leaderElected bool
|
||||
@@ -175,7 +188,10 @@ func NewRaftClusterClient(r *raft.Raft, declaration structure.BackendDeclaration
|
||||
func syncApplyCommand(clusterClient *Client, command []byte, commandName string) {
|
||||
applyLogResponse, err := clusterClient.SyncApply(command)
|
||||
if err != nil {
|
||||
log.Warnf(codes.SyncApplyError, "announce myself. apply %s: %v", commandName, err)
|
||||
log.WithMetadata(map[string]interface{}{
|
||||
"command": string(command),
|
||||
"commandName": commandName,
|
||||
}).Warnf(codes.SyncApplyError, "announce myself. apply command: %v", err)
|
||||
}
|
||||
if applyLogResponse != nil && applyLogResponse.ApplyError != "" {
|
||||
log.WithMetadata(map[string]interface{}{
|
||||
|
||||
@@ -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{
|
||||
@@ -77,7 +84,7 @@ func NewSocketLeaderClient(address string, leaderDisconnectionCallback func()) *
|
||||
leaderClient.client.OnDisconnect(func(err error) {
|
||||
log.WithMetadata(map[string]interface{}{
|
||||
"leaderAddr": address,
|
||||
}).Warn(codes.LeaderClientDisconnected, "leader client disconnected")
|
||||
}).Warn(codes.LeaderClientDisconnected, "disconnected ws from leader")
|
||||
leaderDisconnectionCallback()
|
||||
})
|
||||
|
||||
@@ -85,7 +92,9 @@ func NewSocketLeaderClient(address string, leaderDisconnectionCallback func()) *
|
||||
log.Warnf(codes.LeaderClientConnectionError, "leader client on error: %v", err)
|
||||
})
|
||||
leaderClient.client.OnConnect(func() {
|
||||
log.Debug(0, "leader client connected")
|
||||
log.WithMetadata(map[string]interface{}{
|
||||
"leaderAddr": address,
|
||||
}).Info(codes.LeaderClientConnected, "connected to new leader")
|
||||
})
|
||||
return leaderClient
|
||||
}
|
||||
|
||||
+6
-3
@@ -25,9 +25,12 @@ const (
|
||||
SyncApplyError = 1015
|
||||
|
||||
// Raft Cluster
|
||||
SendDeclarationToLeaderError = 1016
|
||||
LeaderClientConnectionError = 1017
|
||||
LeaderClientDisconnected = 1018
|
||||
SendDeclarationToLeader = 1016
|
||||
LeaderClientConnectionError = 1017
|
||||
LeaderClientDisconnected = 1018
|
||||
LeaderClientConnected = 1023
|
||||
LeaderStateChanged = 1024
|
||||
LeaderManualDeleteLeader = 1025
|
||||
|
||||
// Services
|
||||
DiscoveryServiceSendModulesError = 1019
|
||||
|
||||
+35
-146
@@ -2,7 +2,8 @@ basePath: /api/config
|
||||
definitions:
|
||||
domain.CommonConfigLinks:
|
||||
additionalProperties:
|
||||
items: {}
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type: object
|
||||
domain.CompileConfigsRequest:
|
||||
@@ -12,11 +13,11 @@ definitions:
|
||||
type: string
|
||||
type: array
|
||||
data:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
type: object
|
||||
domain.CompiledConfigResponse:
|
||||
additionalProperties:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
type: object
|
||||
domain.ConfigIdRequest:
|
||||
properties:
|
||||
@@ -204,8 +205,7 @@ definitions:
|
||||
- name
|
||||
type: object
|
||||
entity.ConfigData:
|
||||
additionalProperties:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
type: object
|
||||
entity.ConfigSchema:
|
||||
properties:
|
||||
@@ -239,7 +239,8 @@ definitions:
|
||||
- name
|
||||
type: object
|
||||
jsonschema.Definitions:
|
||||
additionalProperties: {}
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
type: object
|
||||
jsonschema.Schema:
|
||||
properties:
|
||||
@@ -251,19 +252,19 @@ definitions:
|
||||
type: string
|
||||
additionalItems:
|
||||
description: section 5.9
|
||||
type: string
|
||||
type: integer
|
||||
additionalProperties:
|
||||
description: section 5.18
|
||||
type: string
|
||||
allOf:
|
||||
description: section 5.22
|
||||
items:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
type: integer
|
||||
type: array
|
||||
anyOf:
|
||||
description: section 5.23
|
||||
items:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
type: integer
|
||||
type: array
|
||||
binaryEncoding:
|
||||
description: section 4.3
|
||||
@@ -275,6 +276,8 @@ definitions:
|
||||
$ref: '#/definitions/jsonschema.Definitions'
|
||||
type: object
|
||||
dependencies:
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
description: section 5.19
|
||||
type: object
|
||||
description:
|
||||
@@ -296,7 +299,7 @@ definitions:
|
||||
type: string
|
||||
items:
|
||||
description: section 5.9
|
||||
type: string
|
||||
type: integer
|
||||
maxItems:
|
||||
description: section 5.10
|
||||
type: integer
|
||||
@@ -311,7 +314,7 @@ definitions:
|
||||
type: integer
|
||||
media:
|
||||
description: RFC draft-wright-json-schema-hyperschema-00, section 4
|
||||
type: string
|
||||
type: integer
|
||||
minItems:
|
||||
description: section 5.11
|
||||
type: integer
|
||||
@@ -329,19 +332,23 @@ definitions:
|
||||
type: integer
|
||||
not:
|
||||
description: section 5.25
|
||||
type: string
|
||||
type: integer
|
||||
oneOf:
|
||||
description: section 5.24
|
||||
items:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
type: integer
|
||||
type: array
|
||||
pattern:
|
||||
description: section 5.8
|
||||
type: string
|
||||
patternProperties:
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
description: section 5.17
|
||||
type: object
|
||||
properties:
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
description: section 5.16
|
||||
type: object
|
||||
required:
|
||||
@@ -369,19 +376,19 @@ definitions:
|
||||
type: string
|
||||
additionalItems:
|
||||
description: section 5.9
|
||||
type: string
|
||||
type: integer
|
||||
additionalProperties:
|
||||
description: section 5.18
|
||||
type: string
|
||||
allOf:
|
||||
description: section 5.22
|
||||
items:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
type: integer
|
||||
type: array
|
||||
anyOf:
|
||||
description: section 5.23
|
||||
items:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
type: integer
|
||||
type: array
|
||||
binaryEncoding:
|
||||
description: section 4.3
|
||||
@@ -394,6 +401,8 @@ definitions:
|
||||
description: section 5.26
|
||||
type: object
|
||||
dependencies:
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
description: section 5.19
|
||||
type: object
|
||||
description:
|
||||
@@ -415,7 +424,7 @@ definitions:
|
||||
type: string
|
||||
items:
|
||||
description: section 5.9
|
||||
type: string
|
||||
type: integer
|
||||
maxItems:
|
||||
description: section 5.10
|
||||
type: integer
|
||||
@@ -430,7 +439,7 @@ definitions:
|
||||
type: integer
|
||||
media:
|
||||
description: RFC draft-wright-json-schema-hyperschema-00, section 4
|
||||
type: string
|
||||
type: integer
|
||||
minItems:
|
||||
description: section 5.11
|
||||
type: integer
|
||||
@@ -448,19 +457,23 @@ definitions:
|
||||
type: integer
|
||||
not:
|
||||
description: section 5.25
|
||||
type: string
|
||||
type: integer
|
||||
oneOf:
|
||||
description: section 5.24
|
||||
items:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
type: integer
|
||||
type: array
|
||||
pattern:
|
||||
description: section 5.8
|
||||
type: string
|
||||
patternProperties:
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
description: section 5.17
|
||||
type: object
|
||||
properties:
|
||||
additionalProperties:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
description: section 5.16
|
||||
type: object
|
||||
required:
|
||||
@@ -479,123 +492,7 @@ definitions:
|
||||
type: boolean
|
||||
type: object
|
||||
schema.Schema:
|
||||
properties:
|
||||
$ref:
|
||||
description: section 7
|
||||
type: string
|
||||
$schema:
|
||||
description: RFC draft-wright-json-schema-00
|
||||
type: string
|
||||
additionalItems:
|
||||
description: section 5.9
|
||||
type: string
|
||||
additionalProperties:
|
||||
description: section 5.18
|
||||
type: string
|
||||
allOf:
|
||||
description: section 5.22
|
||||
items:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
type: array
|
||||
anyOf:
|
||||
description: section 5.23
|
||||
items:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
type: array
|
||||
binaryEncoding:
|
||||
description: section 4.3
|
||||
type: string
|
||||
default:
|
||||
description: section 6.2
|
||||
type: object
|
||||
definitions:
|
||||
$ref: '#/definitions/jsonschema.Definitions'
|
||||
type: object
|
||||
dependencies:
|
||||
description: section 5.19
|
||||
type: object
|
||||
description:
|
||||
description: section 6.1
|
||||
type: string
|
||||
enum:
|
||||
description: section 5.20
|
||||
items:
|
||||
type: object
|
||||
type: array
|
||||
exclusiveMaximum:
|
||||
description: section 5.3
|
||||
type: boolean
|
||||
exclusiveMinimum:
|
||||
description: section 5.5
|
||||
type: boolean
|
||||
format:
|
||||
description: section 7
|
||||
type: string
|
||||
items:
|
||||
description: section 5.9
|
||||
type: string
|
||||
maxItems:
|
||||
description: section 5.10
|
||||
type: integer
|
||||
maxLength:
|
||||
description: section 5.6
|
||||
type: integer
|
||||
maxProperties:
|
||||
description: section 5.13
|
||||
type: integer
|
||||
maximum:
|
||||
description: section 5.2
|
||||
type: integer
|
||||
media:
|
||||
description: RFC draft-wright-json-schema-hyperschema-00, section 4
|
||||
type: string
|
||||
minItems:
|
||||
description: section 5.11
|
||||
type: integer
|
||||
minLength:
|
||||
description: section 5.7
|
||||
type: integer
|
||||
minProperties:
|
||||
description: section 5.14
|
||||
type: integer
|
||||
minimum:
|
||||
description: section 5.4
|
||||
type: integer
|
||||
multipleOf:
|
||||
description: RFC draft-wright-json-schema-validation-00, section 5
|
||||
type: integer
|
||||
not:
|
||||
description: section 5.25
|
||||
type: string
|
||||
oneOf:
|
||||
description: section 5.24
|
||||
items:
|
||||
$ref: '#/definitions/jsonschema.Type'
|
||||
type: array
|
||||
pattern:
|
||||
description: section 5.8
|
||||
type: string
|
||||
patternProperties:
|
||||
description: section 5.17
|
||||
type: object
|
||||
properties:
|
||||
description: section 5.16
|
||||
type: object
|
||||
required:
|
||||
description: section 5.15
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
title:
|
||||
description: RFC draft-wright-json-schema-validation-00, section 6, 7
|
||||
type: string
|
||||
type:
|
||||
description: section 5.21
|
||||
type: string
|
||||
uniqueItems:
|
||||
description: section 5.12
|
||||
type: boolean
|
||||
type: object
|
||||
$ref: '#/definitions/jsonschema.Schema'
|
||||
structure.AddressConfiguration:
|
||||
properties:
|
||||
ip:
|
||||
@@ -622,6 +519,7 @@ definitions:
|
||||
structure.EndpointDescriptor:
|
||||
properties:
|
||||
extra:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
inner:
|
||||
type: boolean
|
||||
@@ -664,7 +562,6 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/domain.CompileConfigsRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -688,7 +585,6 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/entity.CommonConfig'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -720,7 +616,6 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/domain.ConfigIdRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -766,7 +661,6 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/domain.ConfigIdRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -790,7 +684,6 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/domain.CreateUpdateConfigRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -853,7 +746,6 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/domain.GetByModuleNameRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -885,7 +777,6 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/domain.ConfigIdRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -944,7 +835,6 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/domain.GetByModuleNameRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -1014,7 +904,6 @@ paths:
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/domain.GetByModuleIdRequest'
|
||||
type: object
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
|
||||
@@ -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,
|
||||
@@ -168,7 +170,7 @@ func initRaft(listener net.Listener, clusterCfg conf.ClusterConfiguration, decla
|
||||
addressConfiguration := structure.AddressConfiguration{Port: port, IP: addr.IP.String()}
|
||||
back := structure.BackendDeclaration{ModuleName: cfg.ModuleName, Address: addressConfiguration}
|
||||
log.WithMetadata(map[string]interface{}{"declaration": back}).
|
||||
Debugf(0, "delete disconnected leader's declaration")
|
||||
Infof(codes.LeaderManualDeleteLeader, "manually delete disconnected leader's declaration")
|
||||
service.ClusterMeshService.HandleDeleteBackendDeclarationCommand(back, s)
|
||||
})
|
||||
})
|
||||
|
||||
+4
-3
@@ -2,13 +2,14 @@ package raft
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
|
||||
"github.com/hashicorp/go-hclog"
|
||||
isplog "github.com/integration-system/isp-log"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
"io"
|
||||
"isp-config-service/codes"
|
||||
"log"
|
||||
)
|
||||
|
||||
type LoggerAdapter struct {
|
||||
@@ -17,7 +18,7 @@ type LoggerAdapter struct {
|
||||
|
||||
func (l *LoggerAdapter) Log(level logrus.Level, msg string, args ...interface{}) {
|
||||
if l.name != "" {
|
||||
msg = fmt.Sprintf("%s:%s", l.name, msg)
|
||||
msg = fmt.Sprintf("%s: %s", l.name, msg)
|
||||
}
|
||||
if len(args) != 0 {
|
||||
metadata := make(map[string]interface{}, len(args)/2)
|
||||
|
||||
+5
-1
@@ -3,6 +3,7 @@ package subs
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
etp "github.com/integration-system/isp-etp-go"
|
||||
log "github.com/integration-system/isp-log"
|
||||
"isp-config-service/codes"
|
||||
@@ -21,7 +22,10 @@ func EmitConn(conn etp.Conn, event string, body []byte) {
|
||||
func SyncApplyCommand(command []byte, commandName string) (interface{}, error) {
|
||||
applyLogResponse, err := holder.ClusterClient.SyncApply(command)
|
||||
if err != nil {
|
||||
log.Warnf(codes.SyncApplyError, "apply %s: %v", commandName, err)
|
||||
log.WithMetadata(map[string]interface{}{
|
||||
"command": string(command),
|
||||
"commandName": commandName,
|
||||
}).Warnf(codes.SyncApplyError, "apply command: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
if applyLogResponse != nil && applyLogResponse.ApplyError != "" {
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ func (h *SocketEventHandler) SubscribeAll() {
|
||||
func (h *SocketEventHandler) handleConnect(conn etp.Conn) {
|
||||
isClusterNode := IsConfigClusterNode(conn)
|
||||
moduleName, err := Parameters(conn)
|
||||
log.Debugf(0, "handleConnect: %s", moduleName) // REMOVE
|
||||
log.Debugf(0, "handleConnect from %s", moduleName) // REMOVE
|
||||
if err != nil {
|
||||
EmitConn(conn, utils.ErrorConnection, FormatErrorConnection(err))
|
||||
_ = conn.Close()
|
||||
@@ -81,7 +81,7 @@ func (h *SocketEventHandler) handleConnect(conn etp.Conn) {
|
||||
|
||||
func (h *SocketEventHandler) handleDisconnect(conn etp.Conn, disconnectErr error) {
|
||||
moduleName, _ := Parameters(conn)
|
||||
log.Debugf(0, "handleDisconnect: %s", moduleName) // REMOVE
|
||||
log.Debugf(0, "handleDisconnect from %s", moduleName) // REMOVE
|
||||
if moduleName != "" {
|
||||
holder.EtpServer.Rooms().Leave(conn, moduleName+service.ConfigWatchersRoomSuffix)
|
||||
now := state.GenerateDate()
|
||||
|
||||
Reference in new issue
Block a user