Skip to content

Commit ac4c229

Browse files
committed
no need to marshal group
1 parent cdf54fe commit ac4c229

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func (c *Client) remove(name string) {
220220
}
221221

222222
func (c *Client) reply(payload []byte) error {
223-
dest, req, err := reqUnmarshal(payload)
223+
dest, req, err := reqUnmarshal(c.group, payload)
224224
if err != nil {
225225
return err.(*Error).escalate(errREPL)
226226
}

request.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ import (
1414
type request struct {
1515
Body []byte `json:"body,omitempty"`
1616
Destination string `json:"destination"`
17-
Group string `json:"group"`
1817
Handle string `json:"handle"`
1918
Header map[string][]string `json:"header"`
2019
Method string `json:"method"`
2120
URL string `json:"url"`
2221
}
2322

2423
func reqMarshal(group, dest, handle string, in *http.Request) ([]byte, error) {
25-
out := &request{Group: group}
24+
out := &request{}
2625
if in.Body != nil {
2726
if body, err := ioutil.ReadAll(in.Body); err == nil {
2827
out.Body = body
@@ -43,8 +42,8 @@ func reqMarshal(group, dest, handle string, in *http.Request) ([]byte, error) {
4342
return append([]byte(group+repl), zip(marshalled)...), nil
4443
}
4544

46-
func reqUnmarshal(payload []byte) (*destination, *http.Request, error) {
47-
unzipped, err := unzip(payload)
45+
func reqUnmarshal(group string, p []byte) (*destination, *http.Request, error) {
46+
unzipped, err := unzip(p)
4847
if err != nil {
4948
return nil, nil, err.(*Error).escalate(errReqUnmarshal)
5049
}
@@ -58,7 +57,7 @@ func reqUnmarshal(payload []byte) (*destination, *http.Request, error) {
5857
}
5958
out.Header = http.Header(in.Header)
6059
dest := new(destination)
61-
dest.group = in.Group
60+
dest.group = group
6261
dest.handle = in.Handle
6362
dest.node = in.Destination
6463
return dest, out, nil

response.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ func resMarshal(group string, res *response) []byte {
3030
return append([]byte(group+recv), zip(marshalled)...)
3131
}
3232

33-
func resUnmarshal(payload []byte) (string, *http.Response, error) {
33+
func resUnmarshal(p []byte) (string, *http.Response, error) {
3434
var handle string
3535
var res *http.Response
36-
unzipped, err := unzip(payload)
36+
unzipped, err := unzip(p)
3737
if err != nil {
3838
return handle, res, err.(*Error).escalate(errResUnmarshal)
3939
}

sleuth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func TestError(t *testing.T) {
218218

219219
func TestRequestUnmarshalBadJSON(t *testing.T) {
220220
payload := zip([]byte("{bad json}"))
221-
_, _, err := reqUnmarshal(payload)
221+
_, _, err := reqUnmarshal(GROUP, payload)
222222
if err == nil {
223223
t.Errorf("expected unmarshalReq to fail on bad json")
224224
return

0 commit comments

Comments
 (0)