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