summaryrefslogtreecommitdiffstats
path: root/lib/agent/xdsserver.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2018-03-09 17:28:43 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2018-03-13 12:39:57 +0100
commit80708aa2578f3598fc8abd4d08e576947da22872 (patch)
tree5ec6e414a3f41bea2d157b91f7ef4ac6cb8284a0 /lib/agent/xdsserver.go
parent1499569abc3e8440592add96f96e01791282a246 (diff)
Added api to list and reconnect a XDS-Server.
Added following routes: /servers => list all known XDS-Server /servers/:id => get info of a XDS-Server /servers/:id/reconnect => force reconnection of a XDS-Server Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/agent/xdsserver.go')
-rw-r--r--lib/agent/xdsserver.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/agent/xdsserver.go b/lib/agent/xdsserver.go
index c08bfb1..f74e3ba 100644
--- a/lib/agent/xdsserver.go
+++ b/lib/agent/xdsserver.go
@@ -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
+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)
}