remove unnecessary codes

This commit is contained in:
ykomissarov committed 2019-10-10 13:16:49 +03:00
1 parent ed2e1a0936
commit 78150b2661
5 files changed
+11 -27

No files matched your search

+1 -1
View File
@@ -87,7 +87,7 @@ func (client *ClusterClient) listenLeader() {
client.onClientDisconnect(client.leaderState.leaderAddr)
})
if err := leaderClient.Dial(leaderConnectionTimeout); err != nil {
log.Fatalf(codes.ConnectToLeaderError, "could not connect to leader: %v", err)
log.Fatalf(codes.LeaderClientConnectionError, "could not connect to leader: %v", err)
continue
}
go func(declaration structure.BackendDeclaration) {
+4 -3
View File
@@ -51,7 +51,7 @@ func NewSocketLeaderClient(address string, leaderDisconnectionCallback func()) *
EnableReconnection().
ReconnectionTimeout(1 * time.Second).
OnReconnectionError(func(err error) {
log.Warnf(codes.LeaderClientReconnectionError, "leader client reconnection err: %v", err)
log.Warnf(codes.LeaderClientConnectionError, "leader client reconnection err: %v", err)
}).
BuildToConnect(socketIoAddress)
err := client.On(gosocketio.OnDisconnection, func(channel *gosocketio.Channel) {
@@ -61,8 +61,9 @@ func NewSocketLeaderClient(address string, leaderDisconnectionCallback func()) *
leaderDisconnectionCallback()
})
if err != nil {
log.Fatalf(codes.LeaderClientBindError, "leader client unable to bind event. err: %v", err)
panic(err) ////must never occurred, and will removed in future
}
return &SocketLeaderClient{
c: client,
}
@@ -71,7 +72,7 @@ func NewSocketLeaderClient(address string, leaderDisconnectionCallback func()) *
func getSocketIoUrl(address string) string {
addr, err := net.ResolveTCPAddr("tcp", address)
if err != nil {
panic(err) //must never occured
panic(err) //must never occurred
}
cfg := config.Get().(*conf.Configuration)
+4 -9
View File
@@ -7,8 +7,7 @@ const (
ShutdownHttpServerError = 0
ShutdownHttpServerInfo = 0
ConfigDataSerializeError = 0
SocketIoError = 0
SocketIoError = 0
// Raft
InitRaftError = 0
@@ -19,18 +18,14 @@ const (
RaftShutdownInfo = 0
// Raft Log
InvalidLogDataCommand = 0
ApplyLogCommandError = 0
UnknownLogCommand = 0
PrepareLogCommandError = 0
SyncApplyError = 0
// Raft Cluster
ConnectToLeaderError = 0
SendDeclarationToLeaderError = 0
LeaderClientReconnectionError = 0
LeaderClientDisconnected = 0
LeaderClientBindError = 0
SendDeclarationToLeaderError = 0
LeaderClientConnectionError = 0
LeaderClientDisconnected = 0
// Services
DiscoveryServiceError = 0
-12
View File
@@ -1,24 +1,12 @@
package entity
import (
"encoding/json"
"github.com/integration-system/isp-lib/config/schema"
log "github.com/integration-system/isp-log"
"isp-config-service/codes"
"time"
)
type ConfigData map[string]interface{}
func (cd ConfigData) ToJSON() string {
if bytes, err := json.Marshal(cd); err == nil {
return string(bytes)
} else {
log.Warnf(codes.ConfigDataSerializeError, "could not serialize config data to JSON %v", err)
return "{}"
}
}
type Config struct {
tableName string `sql:"?db_schema.configs" json:"-"`
Id int64 `json:"id"`
+2 -2
View File
@@ -28,7 +28,7 @@ func (s *Store) Apply(l *raft.Log) interface{} {
s.lock.Lock()
defer s.lock.Unlock()
if len(l.Data) < 8 {
log.Fatalf(codes.InvalidLogDataCommand, "invalid log data command: %s", l.Data)
log.Fatalf(codes.ApplyLogCommandError, "invalid log data command: %s", l.Data)
}
command := binary.BigEndian.Uint64(l.Data[:8])
if handler, ok := s.handlers[command]; ok {
@@ -37,7 +37,7 @@ func (s *Store) Apply(l *raft.Log) interface{} {
log.Fatalf(codes.ApplyLogCommandError, "apply log command: %v", err)
}
} else {
log.Fatalf(codes.UnknownLogCommand, "unknown log command %s", command)
log.Fatalf(codes.ApplyLogCommandError, "unknown log command %s", command)
}
return nil
}