1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 18:13:54 +08:00

NoResponse service

This commit is contained in:
Juan Batiz-Benet
2014-09-18 19:42:31 -07:00
committed by Brian Tiger Chow
parent 69b1ce42d9
commit 25d0ce8fdd

View File

@ -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
}