X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fagent%2Fxdsserver.go;h=40ee57b4b5ceef0d4a130d2c417a9c7e18cc12e2;hb=refs%2Ftags%2F7.99.1;hp=c08bfb1b17e6f2e700884271bfbdcc6ddaac1471;hpb=befb10519daefcbee85950a4e574678fe4b7f402;p=src%2Fxds%2Fxds-agent.git diff --git a/lib/agent/xdsserver.go b/lib/agent/xdsserver.go index c08bfb1..40ee57b 100644 --- a/lib/agent/xdsserver.go +++ b/lib/agent/xdsserver.go @@ -26,9 +26,9 @@ import ( "sync" "time" - "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent/lib/xaapiv1" - "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent/lib/xdsconfig" - common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git/golib" + "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent.git/lib/xaapiv1" + "gerrit.automotivelinux.org/gerrit/src/xds/xds-agent.git/lib/xdsconfig" + common "gerrit.automotivelinux.org/gerrit/src/xds/xds-common.git" "gerrit.automotivelinux.org/gerrit/src/xds/xds-server.git/lib/xsapiv1" "github.com/gin-gonic/gin" uuid "github.com/satori/go.uuid" @@ -39,6 +39,7 @@ import ( type XdsServer struct { *Context ID string + URLIndex string BaseURL string APIURL string PartialURL string @@ -83,6 +84,7 @@ func NewXdsServer(ctx *Context, conf xdsconfig.XDSServerConf) *XdsServer { return &XdsServer{ Context: ctx, ID: _IDTempoPrefix + uuid.NewV1().String(), + URLIndex: conf.URLIndex, BaseURL: conf.URL, APIURL: conf.APIBaseURL + conf.APIPartialURL, PartialURL: conf.APIPartialURL, @@ -155,6 +157,19 @@ func (xs *XdsServer) SetLoggerOutput(out io.Writer) { xs.logOut = out } +// GetConfig return the current server config +func (xs *XdsServer) GetConfig() xaapiv1.ServerCfg { + return xaapiv1.ServerCfg{ + ID: xs.ID, + URL: xs.BaseURL, + APIURL: xs.APIURL, + PartialURL: xs.PartialURL, + ConnRetry: xs.ConnRetry, + Connected: xs.Connected, + Disabled: xs.Disabled, + } +} + // SendCommand Send a command to XDS Server func (xs *XdsServer) SendCommand(cmd string, body []byte, res interface{}) error { url := cmd @@ -303,6 +318,7 @@ func (xs *XdsServer) PassthroughPost(url string) { xs._Disconnected() } common.APIError(c, err.Error()) + return }) } @@ -353,6 +369,7 @@ func (xs *XdsServer) PassthroughPut(url string) { xs._Disconnected() } common.APIError(c, err.Error()) + return }) } @@ -396,6 +413,7 @@ func (xs *XdsServer) PassthroughDelete(url string) { xs._Disconnected() } common.APIError(c, err.Error()) + return }) } @@ -683,7 +701,7 @@ func (xs *XdsServer) _SocketConnect() error { }) iosk.On("disconnection", func(err error) { - xs.Log.Infof("IO.socket disconnection server %s", xs.ID) + xs.Log.Infof("IO.socket disconnection server %s (APIURL %s)", xs.ID, xs.APIURL) if xs.CBOnDisconnect != nil { xs.CBOnDisconnect(err) }