Skip to content

Commit

Permalink
perf: optimize communication exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
DokiDoki1103 committed Jan 10, 2024
1 parent 645c9cf commit f36ce1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 5 additions & 8 deletions api/controller/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ type DockerConsole struct {
socketproxy proxy.Proxy
}

var defaultDockerConsoleEndpoints = configs.Default().APIConfig.DockerConsoleServers
var defaultEventLogEndpoints = configs.Default().APIConfig.EventLogEndpoints

var dockerConsole *DockerConsole

// GetDockerConsole get Docker console
Expand All @@ -49,7 +46,7 @@ func GetDockerConsole() *DockerConsole {
return dockerConsole
}
dockerConsole = &DockerConsole{
socketproxy: proxy.CreateProxy("dockerconsole", "websocket", defaultDockerConsoleEndpoints),
socketproxy: proxy.CreateProxy("dockerconsole", "websocket", configs.Default().APIConfig.DockerConsoleServers),
}
//discover.GetEndpointDiscover().AddProject("acp_webcli", dockerConsole.socketproxy)
return dockerConsole
Expand All @@ -71,7 +68,7 @@ type DockerLog struct {
func GetDockerLog() *DockerLog {
if dockerLog == nil {
dockerLog = &DockerLog{
socketproxy: proxy.CreateProxy("dockerlog", "websocket", defaultEventLogEndpoints),
socketproxy: proxy.CreateProxy("dockerlog", "websocket", configs.Default().APIConfig.EventLogEndpoints),
}
//discover.GetEndpointDiscover().AddProject("event_log_event_http", dockerLog.socketproxy)
}
Expand All @@ -94,7 +91,7 @@ var monitorMessage *MonitorMessage
func GetMonitorMessage() *MonitorMessage {
if monitorMessage == nil {
monitorMessage = &MonitorMessage{
socketproxy: proxy.CreateProxy("monitormessage", "websocket", defaultEventLogEndpoints),
socketproxy: proxy.CreateProxy("monitormessage", "websocket", configs.Default().APIConfig.EventLogEndpoints),
}
//discover.GetEndpointDiscover().AddProject("event_log_event_http", monitorMessage.socketproxy)
}
Expand All @@ -117,7 +114,7 @@ var eventLog *EventLog
func GetEventLog() *EventLog {
if eventLog == nil {
eventLog = &EventLog{
socketproxy: proxy.CreateProxy("eventlog", "websocket", defaultEventLogEndpoints),
socketproxy: proxy.CreateProxy("eventlog", "websocket", configs.Default().APIConfig.EventLogEndpoints),
}
//discover.GetEndpointDiscover().AddProject("event_log_event_http", eventLog.socketproxy)
}
Expand Down Expand Up @@ -189,7 +186,7 @@ type PubSubControll struct {
func GetPubSubControll() *PubSubControll {
if pubSubControll == nil {
pubSubControll = &PubSubControll{
socketproxy: proxy.CreateProxy("dockerlog", "websocket", defaultEventLogEndpoints),
socketproxy: proxy.CreateProxy("dockerlog", "websocket", configs.Default().APIConfig.EventLogEndpoints),
}
//discover.GetEndpointDiscover().AddProject("event_log_event_http", pubSubControll.socketproxy)
}
Expand Down
2 changes: 2 additions & 0 deletions config/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ type Config struct {

var defaultConfig *Config

// Default -
func Default() *Config {
return defaultConfig
}

// SetDefault -
func SetDefault(cfg *Config) {
defaultConfig = cfg
}

0 comments on commit f36ce1c

Please sign in to comment.