Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Reduce API component dependency on ETCD #1833

Merged
merged 43 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1763973
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
6b7d7bf
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
e200abd
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
5e3ecf1
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
3cd8311
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
18feabb
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
0c899fd
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
f8d15b1
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
742a68b
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
057a925
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
9d8d6a0
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
7e601ec
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
aecd193
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
f379a9b
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
1e34ca7
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
ada3c8e
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
2912f59
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
9f85f71
perf: optimize communication exceptions
DokiDoki1103 Jan 8, 2024
0f095df
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
4b3258b
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
f3888a0
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
9f3bf36
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
26e1b07
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
cc0d608
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
2717944
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
dbc11e4
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
99420e2
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
bc90fe7
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
82aa86e
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
ba3a682
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
b5eab52
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
e07767f
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
0144a36
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
4a74ebd
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
de5edea
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
a5ab881
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
39d22ce
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
709ec77
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
f9554f5
perf: optimize communication exceptions
DokiDoki1103 Jan 9, 2024
15f126c
perf: optimize communication exceptions
DokiDoki1103 Jan 10, 2024
e28a038
perf: optimize communication exceptions
DokiDoki1103 Jan 10, 2024
645c9cf
perf: optimize communication exceptions
DokiDoki1103 Jan 10, 2024
f36ce1c
perf: optimize communication exceptions
DokiDoki1103 Jan 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions api/controller/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ import (
"net/http"

"github.com/goodrain/rainbond/api/api"
"github.com/goodrain/rainbond/api/discover"
"github.com/goodrain/rainbond/api/proxy"
"github.com/goodrain/rainbond/cmd/api/option"
mqclient "github.com/goodrain/rainbond/mq/client"
etcdutil "github.com/goodrain/rainbond/util/etcd"
"github.com/goodrain/rainbond/worker/client"
)

Expand Down Expand Up @@ -69,13 +67,7 @@ func GetManager() V2Manager {

// NewManager new manager
func NewManager(conf option.Config, statusCli *client.AppRuntimeSyncClient) (*V2Routes, error) {
etcdClientArgs := &etcdutil.ClientArgs{
Endpoints: conf.EtcdEndpoint,
CaFile: conf.EtcdCaFile,
CertFile: conf.EtcdCertFile,
KeyFile: conf.EtcdKeyFile,
}
mqClient, err := mqclient.NewMqClient(etcdClientArgs, conf.MQAPI)
mqClient, err := mqclient.NewMqClient(conf.MQAPI)
if err != nil {
return nil, err
}
Expand All @@ -86,7 +78,7 @@ func NewManager(conf option.Config, statusCli *client.AppRuntimeSyncClient) (*V2
v2r.GatewayStruct.cfg = &conf
v2r.LabelController.optconfig = &conf
eventServerProxy := proxy.CreateProxy("eventlog", "http", []string{"local=>rbd-eventlog:6363"})
discover.GetEndpointDiscover().AddProject("event_log_event_http", eventServerProxy)
//discover.GetEndpointDiscover().AddProject("event_log_event_http", eventServerProxy)
v2r.EventLogStruct.EventlogServerProxy = eventServerProxy
return &v2r, nil
}
51 changes: 25 additions & 26 deletions api/controller/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,118 +25,117 @@ import (
"path"

"github.com/go-chi/chi"
"github.com/goodrain/rainbond/api/discover"
"github.com/goodrain/rainbond/api/handler"
"github.com/goodrain/rainbond/api/proxy"
ctxutil "github.com/goodrain/rainbond/api/util/ctx"
"github.com/goodrain/rainbond/util/constants"
"github.com/sirupsen/logrus"
)

//DockerConsole docker console
// DockerConsole docker console
type DockerConsole struct {
socketproxy proxy.Proxy
}

var defaultDockerConsoleEndpoints = []string{"127.0.0.1:7171"}
var defaultDockerConsoleEndpoints = []string{"rbd-webcli:7171"}
var defaultEventLogEndpoints = []string{"local=>rbd-eventlog:6363"}
DokiDoki1103 marked this conversation as resolved.
Show resolved Hide resolved

var dockerConsole *DockerConsole

//GetDockerConsole get Docker console
// GetDockerConsole get Docker console
func GetDockerConsole() *DockerConsole {
if dockerConsole != nil {
return dockerConsole
}
dockerConsole = &DockerConsole{
socketproxy: proxy.CreateProxy("dockerconsole", "websocket", defaultDockerConsoleEndpoints),
}
discover.GetEndpointDiscover().AddProject("acp_webcli", dockerConsole.socketproxy)
//discover.GetEndpointDiscover().AddProject("acp_webcli", dockerConsole.socketproxy)
return dockerConsole
}

//Get get
// Get get
func (d DockerConsole) Get(w http.ResponseWriter, r *http.Request) {
d.socketproxy.Proxy(w, r)
}

var dockerLog *DockerLog

//DockerLog docker log
// DockerLog docker log
type DockerLog struct {
socketproxy proxy.Proxy
}

//GetDockerLog get docker log
// GetDockerLog get docker log
func GetDockerLog() *DockerLog {
if dockerLog == nil {
dockerLog = &DockerLog{
socketproxy: proxy.CreateProxy("dockerlog", "websocket", defaultEventLogEndpoints),
}
discover.GetEndpointDiscover().AddProject("event_log_event_http", dockerLog.socketproxy)
//discover.GetEndpointDiscover().AddProject("event_log_event_http", dockerLog.socketproxy)
}
return dockerLog
}

//Get get
// Get get
func (d DockerLog) Get(w http.ResponseWriter, r *http.Request) {
d.socketproxy.Proxy(w, r)
}

//MonitorMessage monitor message
// MonitorMessage monitor message
type MonitorMessage struct {
socketproxy proxy.Proxy
}

var monitorMessage *MonitorMessage

//GetMonitorMessage get MonitorMessage
// GetMonitorMessage get MonitorMessage
func GetMonitorMessage() *MonitorMessage {
if monitorMessage == nil {
monitorMessage = &MonitorMessage{
socketproxy: proxy.CreateProxy("monitormessage", "websocket", defaultEventLogEndpoints),
}
discover.GetEndpointDiscover().AddProject("event_log_event_http", monitorMessage.socketproxy)
//discover.GetEndpointDiscover().AddProject("event_log_event_http", monitorMessage.socketproxy)
}
return monitorMessage
}

//Get get
// Get get
func (d MonitorMessage) Get(w http.ResponseWriter, r *http.Request) {
d.socketproxy.Proxy(w, r)
}

//EventLog event log
// EventLog event log
type EventLog struct {
socketproxy proxy.Proxy
}

var eventLog *EventLog

//GetEventLog get event log
// GetEventLog get event log
func GetEventLog() *EventLog {
if eventLog == nil {
eventLog = &EventLog{
socketproxy: proxy.CreateProxy("eventlog", "websocket", defaultEventLogEndpoints),
}
discover.GetEndpointDiscover().AddProject("event_log_event_http", eventLog.socketproxy)
//discover.GetEndpointDiscover().AddProject("event_log_event_http", eventLog.socketproxy)
}
return eventLog
}

//Get get
// Get get
func (d EventLog) Get(w http.ResponseWriter, r *http.Request) {
d.socketproxy.Proxy(w, r)
}

//LogFile log file down server
// LogFile log file down server
type LogFile struct {
Root string
}

var logFile *LogFile

//GetLogFile get log file
// GetLogFile get log file
func GetLogFile() *LogFile {
root := os.Getenv("SERVICE_LOG_ROOT")
if root == "" {
Expand All @@ -151,7 +150,7 @@ func GetLogFile() *LogFile {
return logFile
}

//Get get
// Get get
func (d LogFile) Get(w http.ResponseWriter, r *http.Request) {
gid := chi.URLParam(r, "gid")
filename := chi.URLParam(r, "filename")
Expand Down Expand Up @@ -180,23 +179,23 @@ func (d LogFile) GetInstallLog(w http.ResponseWriter, r *http.Request) {

var pubSubControll *PubSubControll

//PubSubControll service pub sub
// PubSubControll service pub sub
type PubSubControll struct {
socketproxy proxy.Proxy
}

//GetPubSubControll get service pub sub controller
// GetPubSubControll get service pub sub controller
func GetPubSubControll() *PubSubControll {
if pubSubControll == nil {
pubSubControll = &PubSubControll{
socketproxy: proxy.CreateProxy("dockerlog", "websocket", defaultEventLogEndpoints),
}
discover.GetEndpointDiscover().AddProject("event_log_event_http", pubSubControll.socketproxy)
//discover.GetEndpointDiscover().AddProject("event_log_event_http", pubSubControll.socketproxy)
}
return pubSubControll
}

//Get pubsub controller
// Get pubsub controller
func (d PubSubControll) Get(w http.ResponseWriter, r *http.Request) {
serviceID := chi.URLParam(r, "serviceID")
name, _ := handler.GetEventHandler().GetLogInstance(serviceID)
Expand All @@ -207,7 +206,7 @@ func (d PubSubControll) Get(w http.ResponseWriter, r *http.Request) {
d.socketproxy.Proxy(w, r)
}

//GetHistoryLog get service docker logs
// GetHistoryLog get service docker logs
func (d PubSubControll) GetHistoryLog(w http.ResponseWriter, r *http.Request) {
serviceID := r.Context().Value(ctxutil.ContextKey("service_id")).(string)
name, _ := handler.GetEventHandler().GetLogInstance(serviceID)
Expand Down
65 changes: 0 additions & 65 deletions api/daemon/region_api.go

This file was deleted.

Loading
Loading