mirror of
https://github.com/linka-cloud/grpc.git
synced 2025-06-22 09:12:28 +00:00
proxy: use grpc interfaces instead of *grpc.Server and *grpc.ClientConn, use Service and service Options
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
@ -14,26 +14,27 @@ import (
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"go.linka.cloud/grpc-toolkit/proxy"
|
||||
"go.linka.cloud/grpc-toolkit/service"
|
||||
)
|
||||
|
||||
var (
|
||||
director proxy.StreamDirector
|
||||
)
|
||||
|
||||
func ExampleNewProxy() {
|
||||
func ExampleNew() {
|
||||
dst, err := grpc.Dial("example.com")
|
||||
if err != nil {
|
||||
log.Fatalf("dialing example.org: %v", err)
|
||||
}
|
||||
proxy := proxy.NewProxy(dst)
|
||||
proxy, _ := proxy.New(dst)
|
||||
_ = proxy
|
||||
}
|
||||
|
||||
func ExampleRegisterService() {
|
||||
// A gRPC server with the proxying codec enabled.
|
||||
server := grpc.NewServer()
|
||||
// A gRPC service with the proxying codec enabled.
|
||||
svc, _ := service.New()
|
||||
// Register a TestService with 4 of its methods explicitly.
|
||||
proxy.RegisterService(server, director,
|
||||
proxy.RegisterService(svc, director,
|
||||
"mwitkow.testproto.TestService",
|
||||
"PingEmpty", "Ping", "PingError", "PingList")
|
||||
}
|
||||
|
Reference in New Issue
Block a user