Add client comments
This commit is contained in:
parent
24b8cd3d97
commit
ad6e8194ed
@ -41,42 +41,55 @@ var (
|
|||||||
DefaultClient Client = newRpcClient()
|
DefaultClient Client = newRpcClient()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Makes a synchronous call to a service using the default client
|
||||||
func Call(ctx context.Context, request Request, response interface{}) error {
|
func Call(ctx context.Context, request Request, response interface{}) error {
|
||||||
return DefaultClient.Call(ctx, request, response)
|
return DefaultClient.Call(ctx, request, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Makes a synchronous call to the specified address using the default client
|
||||||
func CallRemote(ctx context.Context, address string, request Request, response interface{}) error {
|
func CallRemote(ctx context.Context, address string, request Request, response interface{}) error {
|
||||||
return DefaultClient.CallRemote(ctx, address, request, response)
|
return DefaultClient.CallRemote(ctx, address, request, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates a streaming connection with a service and returns responses on the
|
||||||
|
// channel passed in. It's upto the user to close the streamer.
|
||||||
func Stream(ctx context.Context, request Request, responseChan interface{}) (Streamer, error) {
|
func Stream(ctx context.Context, request Request, responseChan interface{}) (Streamer, error) {
|
||||||
return DefaultClient.Stream(ctx, request, responseChan)
|
return DefaultClient.Stream(ctx, request, responseChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates a streaming connection to the address specified.
|
||||||
func StreamRemote(ctx context.Context, address string, request Request, responseChan interface{}) (Streamer, error) {
|
func StreamRemote(ctx context.Context, address string, request Request, responseChan interface{}) (Streamer, error) {
|
||||||
return DefaultClient.StreamRemote(ctx, address, request, responseChan)
|
return DefaultClient.StreamRemote(ctx, address, request, responseChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Publishes a publication using the default client. Using the underlying broker
|
||||||
|
// set within the options.
|
||||||
func Publish(ctx context.Context, p Publication) error {
|
func Publish(ctx context.Context, p Publication) error {
|
||||||
return DefaultClient.Publish(ctx, p)
|
return DefaultClient.Publish(ctx, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates a new client with the options passed in
|
||||||
func NewClient(opt ...Option) Client {
|
func NewClient(opt ...Option) Client {
|
||||||
return newRpcClient(opt...)
|
return newRpcClient(opt...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates a new publication using the default client
|
||||||
func NewPublication(topic string, message interface{}) Publication {
|
func NewPublication(topic string, message interface{}) Publication {
|
||||||
return DefaultClient.NewPublication(topic, message)
|
return DefaultClient.NewPublication(topic, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates a new request using the default client. Content Type will
|
||||||
|
// be set to the default within options and use the appropriate codec
|
||||||
func NewRequest(service, method string, request interface{}) Request {
|
func NewRequest(service, method string, request interface{}) Request {
|
||||||
return DefaultClient.NewRequest(service, method, request)
|
return DefaultClient.NewRequest(service, method, request)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates a new protobuf request using the default client
|
||||||
func NewProtoRequest(service, method string, request interface{}) Request {
|
func NewProtoRequest(service, method string, request interface{}) Request {
|
||||||
return DefaultClient.NewProtoRequest(service, method, request)
|
return DefaultClient.NewProtoRequest(service, method, request)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates a new json request using the default client
|
||||||
func NewJsonRequest(service, method string, request interface{}) Request {
|
func NewJsonRequest(service, method string, request interface{}) Request {
|
||||||
return DefaultClient.NewJsonRequest(service, method, request)
|
return DefaultClient.NewJsonRequest(service, method, request)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ and pub/sub.
|
|||||||
*/
|
*/
|
||||||
package server
|
package server
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
Loading…
Reference in New Issue
Block a user