go.uber.org/yarpc@v1.72.1/transport/grpc/doc.go (about) 1 // Copyright (c) 2022 Uber Technologies, Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 // Package grpc implements a YARPC transport based on the gRPC protocol. 22 // The gRPC transport provides support for unary and streaming RPCs. 23 // 24 // Usage 25 // 26 // A gRPC Transport must be constructed to use this transport. 27 // 28 // grpcTransport := grpc.NewTransport() 29 // 30 // To serve your YARPC application over gRPC, pass a gRPC inbound in your 31 // yarpc.Config. 32 // 33 // listener, err := net.Listen("tcp", ":8080") 34 // if err != nil { 35 // return err 36 // } 37 // myInbound := grpcTransport.NewInbound(listener) 38 // dispatcher := yarpc.NewDispatcher(yarpc.Config{ 39 // Name: "myservice", 40 // Inbounds: yarpc.Inbounds{myInbound}, 41 // }) 42 // 43 // To configure TLS on your service listener, pass 44 // credentials.TransportCredentials as an InboundCredentials InboundOption. 45 // There are various ways to create credentials.TransportCredentials. See 46 // https://godoc.org/google.golang.org/grpc/credentials#TransportCredentials. 47 // 48 // listener, err := net.Listen("tcp", ":4443") 49 // if err != nil { 50 // return err 51 // } 52 // 53 // myTLSConfig := &tls.Config{ 54 // // any arbitrary valid tls.Config 55 // } 56 // myTransportCredentials := credentials.NewTLS(myTLSConfig) 57 // myInbound := grpcTransport.NewInbound( 58 // listener, 59 // InboundCredentials(myInboundCredentials), 60 // ) 61 // dispatcher := yarpc.NewDispatcher(yarpc.Config{ 62 // Name: "myservice", 63 // Inbounds: yarpc.Inbounds{myInbound}, 64 // }) 65 // 66 // To make requests to a YARPC application that supports gRPC, pass a gRPC 67 // outbound in your yarpc.Config. 68 // 69 // myserviceOutbound := grpcTransport.NewSingleOutbound("127.0.0.1:8080") 70 // dispatcher := yarpc.NewDispatcher(yarpc.Config{ 71 // Name: "myclient", 72 // Outbounds: yarpc.Outbounds{ 73 // "myservice": {Unary: myserviceOutbound}, 74 // }, 75 // }) 76 // 77 // To make requests using TLS to an application supporting gRPC over TLS, pass 78 // credentials.TransportCredentials as a DialerCredentials DialOption. There 79 // are various ways to create credentials.TransportCredentials. See 80 // https://godoc.org/google.golang.org/grpc/credentials#TransportCredentials. 81 // 82 // myTLSConfig := &tls.Config{ 83 // // any arbitrary valid tls.Config 84 // } 85 // myTransportCredentials := credentials.NewTLS(myTLSConfig) 86 // myChooser := peer.NewSingle( 87 // hostport.Identify("127.0.0.1:4443"), 88 // grpcTransport.NewDialer(DialerCredentials(myTransportCredentials)), 89 // ) 90 // myserviceOutbound := grpcTransport.NewOutbound(myChooser) 91 // dispatcher := yarpc.NewDispatcher(yarpc.Config{ 92 // Name: "myclient", 93 // Outbounds: yarpc.Outbounds{ 94 // "myservice": {Unary: myserviceOutbound}, 95 // }, 96 // }) 97 // 98 // Configuration 99 // 100 // A gRPC transport may be configured using YARPC's configuration system. 101 // See TransportConfig, InboundConfig, and OutboundConfig for details on the 102 // different configuration parameters supported by this transport. 103 // 104 // See Also 105 // 106 // gRPC Project Page: https://grpc.io 107 // gRPC Wire Protocol Definition: https://grpc.io/docs/guides/wire.html 108 // gRPC Golang Library: https://github.com/grpc/grpc-go 109 package grpc