Commit 25d0ce8f authored by Juan Batiz-Benet's avatar Juan Batiz-Benet Committed by Brian Tiger Chow

NoResponse service

parent 69b1ce42
......@@ -10,6 +10,10 @@ import (
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
)
// ErrNoResponse is returned by Service when a Request did not get a response,
// and no other error happened
var ErrNoResponse = errors.New("no response to request")
// Handler is an interface that objects must implement in order to handle
// a service's requests.
type Handler interface {
......@@ -134,6 +138,10 @@ func (s *Service) SendRequest(ctx context.Context, m msg.NetMessage) (msg.NetMes
err = ctx.Err()
}
if m == nil {
return nil, ErrNoResponse
}
return m, err
}
......@@ -205,6 +213,7 @@ func (s *Service) handleIncomingMessage(ctx context.Context, m msg.NetMessage) {
}
}
// SetHandler assigns the request Handler for this service.
func (s *Service) SetHandler(h Handler) {
s.Handler = h
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment