Skip to content

Commit

Permalink
Rename newResponseWriter, switch to whisperer interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
afshin committed Jun 5, 2016
1 parent f72bb45 commit 4a6d221
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (c *Client) reply(payload []byte) error {
if err != nil {
return err.(*Error).escalate(errREPL)
}
c.handler.ServeHTTP(newResponseWriter(c.node, dest), req)
c.handler.ServeHTTP(newWriter(c.node, dest), req)
return nil
}

Expand Down
22 changes: 11 additions & 11 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

package sleuth

import (
"net/http"
import "net/http"

"github.com/zeromq/gyre"
)
type whisperer interface {
Whisper(addr string, payload []byte) error
}

type writer struct {
http.ResponseWriter
node *gyre.Gyre
output *response
peer string
output *response
peer string
whisperer whisperer
}

func (w *writer) Header() http.Header {
Expand All @@ -31,7 +31,7 @@ func (w *writer) Write(data []byte) (int, error) {
}
w.output.Body = data
payload := marshalResponse(w.output)
if err := w.node.Whisper(w.peer, payload); err != nil {
if err := w.whisperer.Whisper(w.peer, payload); err != nil {
return 0, newError(errResWhisper, err.Error())
}
return len(data), nil
Expand All @@ -41,11 +41,11 @@ func (w *writer) WriteHeader(code int) {
w.output.Code = code
}

func newResponseWriter(node *gyre.Gyre, dest *destination) *writer {
func newWriter(node whisperer, dest *destination) *writer {
return &writer{
node: node,
output: &response{
Handle: dest.handle,
Header: http.Header(make(map[string][]string))},
peer: dest.node}
peer: dest.node,
whisperer: node}
}

0 comments on commit 4a6d221

Please sign in to comment.