mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 02:30:45 +00:00
Merge pull request #1100 from weaveworks/pipe-app-id
Have the probe fill in the app id, not the app
This commit is contained in:
@@ -31,7 +31,6 @@ func handleControl(cr ControlRouter) CtxHandlerFunc {
|
||||
control = vars["control"]
|
||||
)
|
||||
result, err := cr.Handle(ctx, probeID, xfer.Request{
|
||||
AppID: UniqueID,
|
||||
NodeID: nodeID,
|
||||
Control: control,
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@ var ErrInvalidMessage = fmt.Errorf("Invalid Message")
|
||||
|
||||
// Request is the UI -> App -> Probe message type for control RPCs
|
||||
type Request struct {
|
||||
AppID string
|
||||
AppID string // filled in by the probe on receiving this request
|
||||
NodeID string
|
||||
Control string
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ type appClient struct {
|
||||
target string
|
||||
client http.Client
|
||||
wsDialer websocket.Dialer
|
||||
appID string
|
||||
|
||||
// Track all the background goroutines, ensure they all stop
|
||||
backgroundWait sync.WaitGroup
|
||||
@@ -150,7 +151,11 @@ func (c *appClient) Details() (xfer.Details, error) {
|
||||
return result, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
return result, codec.NewDecoder(resp.Body, &codec.JsonHandle{}).Decode(&result)
|
||||
if err := codec.NewDecoder(resp.Body, &codec.JsonHandle{}).Decode(&result); err != nil {
|
||||
return result, err
|
||||
}
|
||||
c.appID = result.ID
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *appClient) doWithBackoff(msg string, f func() (bool, error)) {
|
||||
@@ -194,9 +199,16 @@ func (c *appClient) controlConnection() (bool, error) {
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
doControl := func(req xfer.Request) xfer.Response {
|
||||
req.AppID = c.appID
|
||||
var res xfer.Response
|
||||
c.control.Handle(req, &res)
|
||||
return res
|
||||
}
|
||||
|
||||
codec := xfer.NewJSONWebsocketCodec(conn)
|
||||
server := rpc.NewServer()
|
||||
if err := server.RegisterName("control", c.control); err != nil {
|
||||
if err := server.RegisterName("control", xfer.ControlHandlerFunc(doControl)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user