2015-12-02 00:47:52 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
2015-12-02 21:16:44 +00:00
|
|
|
// HandlerFunc represents a single method of a handler. It's used primarily
|
|
|
|
// for the wrappers. What's handed to the actual method is the concrete
|
|
|
|
// request and response types.
|
2015-12-02 20:56:50 +00:00
|
|
|
type HandlerFunc func(ctx context.Context, req Request, rsp interface{}) error
|
2015-12-02 00:47:52 +00:00
|
|
|
|
2015-12-02 21:16:44 +00:00
|
|
|
// SubscriberFunc represents a single method of a subscriber. It's used primarily
|
|
|
|
// for the wrappers. What's handed to the actual method is the concrete
|
|
|
|
// publication message.
|
2015-12-02 20:56:50 +00:00
|
|
|
type SubscriberFunc func(ctx context.Context, msg Publication) error
|
2015-12-02 11:54:36 +00:00
|
|
|
|
2015-12-02 21:16:44 +00:00
|
|
|
// HandlerWrapper wraps the HandlerFunc and returns the equivalent
|
2015-12-02 11:54:36 +00:00
|
|
|
type HandlerWrapper func(HandlerFunc) HandlerFunc
|
|
|
|
|
2015-12-02 21:16:44 +00:00
|
|
|
// SubscriberWrapper wraps the SubscriberFunc and returns the equivalent
|
2015-12-02 11:54:36 +00:00
|
|
|
type SubscriberWrapper func(SubscriberFunc) SubscriberFunc
|
2015-12-17 20:37:35 +00:00
|
|
|
|
2015-12-18 01:01:59 +00:00
|
|
|
// StreamerWrapper wraps a Streamer interface and returns the equivalent.
|
|
|
|
// Because streams exist for the lifetime of a method invocation this
|
|
|
|
// is a convenient way to wrap a Stream as its in use for trace, monitoring,
|
|
|
|
// metrics, etc.
|
|
|
|
type StreamerWrapper func(Streamer) Streamer
|