1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-06 08:16:03 +02:00
go-micro/server/wrapper.go

28 lines
1.0 KiB
Go
Raw Normal View History

package server
import (
2018-03-03 13:53:52 +02:00
"context"
)
2015-12-02 23:16:44 +02: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 22:56:50 +02:00
type HandlerFunc func(ctx context.Context, req Request, rsp interface{}) error
2015-12-02 23:16:44 +02: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.
2018-04-14 19:21:02 +02:00
type SubscriberFunc func(ctx context.Context, msg Message) error
2015-12-02 13:54:36 +02:00
2015-12-02 23:16:44 +02:00
// HandlerWrapper wraps the HandlerFunc and returns the equivalent
2015-12-02 13:54:36 +02:00
type HandlerWrapper func(HandlerFunc) HandlerFunc
2015-12-02 23:16:44 +02:00
// SubscriberWrapper wraps the SubscriberFunc and returns the equivalent
2015-12-02 13:54:36 +02:00
type SubscriberWrapper func(SubscriberFunc) SubscriberFunc
2015-12-17 22:37:35 +02:00
2018-04-14 19:15:09 +02:00
// StreamWrapper wraps a Stream interface and returns the equivalent.
2015-12-18 03:01:59 +02:00
// 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.
2018-04-14 19:15:09 +02:00
type StreamWrapper func(Stream) Stream