...
1
16
17 package ttrpc
18
19 import "context"
20
21
22 type UnaryServerInfo struct {
23 FullMethod string
24 }
25
26
27 type UnaryClientInfo struct {
28 FullMethod string
29 }
30
31
32 type StreamServerInfo struct {
33 FullMethod string
34 StreamingClient bool
35 StreamingServer bool
36 }
37
38
39
40 type Unmarshaler func(interface{}) error
41
42
43 type Invoker func(context.Context, *Request, *Response) error
44
45
46 type UnaryServerInterceptor func(context.Context, Unmarshaler, *UnaryServerInfo, Method) (interface{}, error)
47
48
49 type UnaryClientInterceptor func(context.Context, *Request, *Response, *UnaryClientInfo, Invoker) error
50
51 func defaultServerInterceptor(ctx context.Context, unmarshal Unmarshaler, _ *UnaryServerInfo, method Method) (interface{}, error) {
52 return method(ctx, unmarshal)
53 }
54
55 func defaultClientInterceptor(ctx context.Context, req *Request, resp *Response, _ *UnaryClientInfo, invoker Invoker) error {
56 return invoker(ctx, req, resp)
57 }
58
59 type StreamServerInterceptor func(context.Context, StreamServer, *StreamServerInfo, StreamHandler) (interface{}, error)
60
61 func defaultStreamServerInterceptor(ctx context.Context, ss StreamServer, _ *StreamServerInfo, stream StreamHandler) (interface{}, error) {
62 return stream(ctx, ss)
63 }
64
65 type StreamClientInterceptor func(context.Context)
66
View as plain text