Add client comments
This commit is contained in:
parent
24b8cd3d97
commit
ad6e8194ed
@ -41,42 +41,55 @@ var (
|
||||
DefaultClient Client = newRpcClient()
|
||||
)
|
||||
|
||||
// Makes a synchronous call to a service using the default client
|
||||
func Call(ctx context.Context, request Request, response interface{}) error {
|
||||
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 {
|
||||
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) {
|
||||
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) {
|
||||
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 {
|
||||
return DefaultClient.Publish(ctx, p)
|
||||
}
|
||||
|
||||
// Creates a new client with the options passed in
|
||||
func NewClient(opt ...Option) Client {
|
||||
return newRpcClient(opt...)
|
||||
}
|
||||
|
||||
// Creates a new publication using the default client
|
||||
func NewPublication(topic string, message interface{}) Publication {
|
||||
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 {
|
||||
return DefaultClient.NewRequest(service, method, request)
|
||||
}
|
||||
|
||||
// Creates a new protobuf request using the default client
|
||||
func NewProtoRequest(service, method string, request interface{}) Request {
|
||||
return DefaultClient.NewProtoRequest(service, method, request)
|
||||
}
|
||||
|
||||
// Creates a new json request using the default client
|
||||
func NewJsonRequest(service, method string, request interface{}) Request {
|
||||
return DefaultClient.NewJsonRequest(service, method, request)
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
/*
|
||||
Server represents a server instance in go-micro which handles synchronous
|
||||
requests via handlers and asynchronous requests via subscribers that
|
||||
/*
|
||||
Server represents a server instance in go-micro which handles synchronous
|
||||
requests via handlers and asynchronous requests via subscribers that
|
||||
register with a broker.
|
||||
|
||||
The server combines the all the packages in go-micro to create a whole unit
|
||||
used for building applications including discovery, client/server communication
|
||||
The server combines the all the packages in go-micro to create a whole unit
|
||||
used for building applications including discovery, client/server communication
|
||||
and pub/sub.
|
||||
*/
|
||||
package server
|
||||
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
|
Loading…
Reference in New Issue
Block a user