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

Have the probe fill in the app id, not the app #1086

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion app/controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down
2 changes: 1 addition & 1 deletion common/xfer/controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 14 additions & 2 deletions probe/appclient/app_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion tools/lint
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function spell_check {
filename="$1"
local lint_result=0

if grep -iH --color=always 'psueod\|availible' "${filename}"; then
if grep -iH --color=always 'psueod\|availible\|reciept' "${filename}"; then
echo "${filename}: spelling mistake"
lint_result=1
fi
Expand Down