@@ -12,22 +12,18 @@ import (
1212type Client interface {
1313 Init (... Option ) error
1414 Options () Options
15- NewPublication (topic string , msg interface {}) Publication
15+ NewMessage (topic string , msg interface {}) Message
1616 NewRequest (service , method string , req interface {}, reqOpts ... RequestOption ) Request
17- NewProtoRequest (service , method string , req interface {}, reqOpts ... RequestOption ) Request
18- NewJsonRequest (service , method string , req interface {}, reqOpts ... RequestOption ) Request
1917 Call (ctx context.Context , req Request , rsp interface {}, opts ... CallOption ) error
20- CallRemote (ctx context.Context , addr string , req Request , rsp interface {}, opts ... CallOption ) error
21- Stream (ctx context.Context , req Request , opts ... CallOption ) (Streamer , error )
22- StreamRemote (ctx context.Context , addr string , req Request , opts ... CallOption ) (Streamer , error )
23- Publish (ctx context.Context , p Publication , opts ... PublishOption ) error
18+ Stream (ctx context.Context , req Request , opts ... CallOption ) (Stream , error )
19+ Publish (ctx context.Context , msg Message , opts ... PublishOption ) error
2420 String () string
2521}
2622
27- // Publication is the interface for a message published asynchronously
28- type Publication interface {
23+ // Message is the interface for publishing asynchronously
24+ type Message interface {
2925 Topic () string
30- Message () interface {}
26+ Payload () interface {}
3127 ContentType () string
3228}
3329
@@ -41,8 +37,8 @@ type Request interface {
4137 Stream () bool
4238}
4339
44- // Streamer is the inteface for a bidirectional synchronous stream
45- type Streamer interface {
40+ // Stream is the inteface for a bidirectional synchronous stream
41+ type Stream interface {
4642 Context () context.Context
4743 Request () Request
4844 Send (interface {}) error
@@ -85,52 +81,32 @@ func Call(ctx context.Context, request Request, response interface{}, opts ...Ca
8581 return DefaultClient .Call (ctx , request , response , opts ... )
8682}
8783
88- // Makes a synchronous call to the specified address using the default client
89- func CallRemote (ctx context.Context , address string , request Request , response interface {}, opts ... CallOption ) error {
90- return DefaultClient .CallRemote (ctx , address , request , response , opts ... )
91- }
92-
93- // Creates a streaming connection with a service and returns responses on the
94- // channel passed in. It's up to the user to close the streamer.
95- func Stream (ctx context.Context , request Request , opts ... CallOption ) (Streamer , error ) {
96- return DefaultClient .Stream (ctx , request , opts ... )
97- }
98-
99- // Creates a streaming connection to the address specified.
100- func StreamRemote (ctx context.Context , address string , request Request , opts ... CallOption ) (Streamer , error ) {
101- return DefaultClient .StreamRemote (ctx , address , request , opts ... )
102- }
103-
10484// Publishes a publication using the default client. Using the underlying broker
10585// set within the options.
106- func Publish (ctx context.Context , p Publication ) error {
107- return DefaultClient .Publish (ctx , p )
86+ func Publish (ctx context.Context , msg Message ) error {
87+ return DefaultClient .Publish (ctx , msg )
88+ }
89+
90+ // Creates a new message using the default client
91+ func NewMessage (topic string , payload interface {}) Message {
92+ return DefaultClient .NewMessage (topic , payload )
10893}
10994
11095// Creates a new client with the options passed in
11196func NewClient (opt ... Option ) Client {
11297 return newRpcClient (opt ... )
11398}
11499
115- // Creates a new publication using the default client
116- func NewPublication (topic string , message interface {}) Publication {
117- return DefaultClient .NewPublication (topic , message )
118- }
119-
120100// Creates a new request using the default client. Content Type will
121101// be set to the default within options and use the appropriate codec
122102func NewRequest (service , method string , request interface {}, reqOpts ... RequestOption ) Request {
123103 return DefaultClient .NewRequest (service , method , request , reqOpts ... )
124104}
125105
126- // Creates a new protobuf request using the default client
127- func NewProtoRequest (service , method string , request interface {}, reqOpts ... RequestOption ) Request {
128- return DefaultClient .NewProtoRequest (service , method , request , reqOpts ... )
129- }
130-
131- // Creates a new json request using the default client
132- func NewJsonRequest (service , method string , request interface {}, reqOpts ... RequestOption ) Request {
133- return DefaultClient .NewJsonRequest (service , method , request , reqOpts ... )
106+ // Creates a streaming connection with a service and returns responses on the
107+ // channel passed in. It's up to the user to close the streamer.
108+ func NewStream (ctx context.Context , request Request , opts ... CallOption ) (Stream , error ) {
109+ return DefaultClient .Stream (ctx , request , opts ... )
134110}
135111
136112func String () string {
0 commit comments