33This document will provide an overview of the gRPC API for Swift.
44It follows a standard form used by each language-platform implementation.
55
6- ##Basic Functionality
6+ ## Basic Functionality
77
88The following examples use [ echo.proto] ( Examples/Echo/echo.proto ) to demonstrate
99basic gRPC operation and generated code.
1010
11- ###How is a New Stub Created?
11+ ### How is a New Stub Created?
1212
1313Swift gRPC client and server code is generated by the ` protoc-gen-swiftgrpc ` plugin.
1414The plugin is called from ` protoc ` and can be invoked for ` echo.proto ` like this:
1515
1616 protoc Examples/Echo/echo.proto --proto_path=Examples/Echo --swiftgrpc_out=.
1717
18- ###Simple Request-Response RPC: Client-side RPC
18+ ### Simple Request-Response RPC: Client-side RPC
1919
2020 var requestMessage = Echo_EchoRequest(text:message)
2121 print("Sending: " + requestMessage.text)
2222 let responseMessage = try service.get(requestMessage)
2323 print("get received: " + responseMessage.text)
2424
25- ###Simple Request-Response RPC: Server Implementation of RPC
25+ ### Simple Request-Response RPC: Server Implementation of RPC
2626
2727 // get returns requests as they were received.
2828 func get(request : Echo_EchoRequest) throws -> Echo_EchoResponse {
2929 return Echo_EchoResponse(text:"Swift echo get: " + request.text)
3030 }
3131
32- ###Show how Client does two RPCs sequentially
32+ ### Show how Client does two RPCs sequentially
3333
3434
35- ###Show how Client does two RPCs asynchronously
35+ ### Show how Client does two RPCs asynchronously
3636
3737
38- ###Any code for handling incoming RPC on server that might need to be written
38+ ### Any code for handling incoming RPC on server that might need to be written
3939
4040
41- ###Server Streaming RPC: Client-side code
41+ ### Server Streaming RPC: Client-side code
4242
4343 let requestMessage = Echo_EchoRequest(text:message)
4444 print("Sending: " + requestMessage.text)
@@ -54,7 +54,7 @@ The plugin is called from `protoc` and can be invoked for `echo.proto` like this
5454 }
5555 }
5656
57- ###Server Streaming RPC: Server-side code
57+ ### Server Streaming RPC: Server-side code
5858
5959 // expand splits a request into words and returns each word in a separate message.
6060 func expand(request : Echo_EchoRequest, session : Echo_EchoExpandSession) throws -> Void {
@@ -67,7 +67,7 @@ The plugin is called from `protoc` and can be invoked for `echo.proto` like this
6767 }
6868 }
6969
70- ###How is a Server Created?
70+ ### How is a Server Created?
7171
7272 var done = NSCondition()
7373 let echoProvider = EchoProvider()
@@ -92,13 +92,13 @@ The plugin is called from `protoc` and can be invoked for `echo.proto` like this
9292 done.wait()
9393 done.unlock()
9494
95- ##Advanced
95+ ## Advanced
9696
97- ###RPC canceling on client side
97+ ### RPC canceling on client side
9898
99- ###Code to look for and handle cancelled RPC on Server side
99+ ### Code to look for and handle cancelled RPC on Server side
100100
101- ###Client Streaming RPC: Client-side code
101+ ### Client Streaming RPC: Client-side code
102102
103103 let collectCall = try service.collect()
104104 let parts = message.components(separatedBy:" ")
@@ -110,7 +110,7 @@ The plugin is called from `protoc` and can be invoked for `echo.proto` like this
110110 }
111111 let responseMessage = try collectCall.CloseAndReceive()
112112
113- ###Client Streaming RPC: Server-side code
113+ ### Client Streaming RPC: Server-side code
114114
115115 // collect collects a sequence of messages and returns them concatenated when the caller closes.
116116 func collect(session : Echo_EchoCollectSession) throws -> Void {
@@ -129,11 +129,11 @@ The plugin is called from `protoc` and can be invoked for `echo.proto` like this
129129 try session.SendAndClose(response)
130130 }
131131
132- ###Flow control interactions while sending & receiving messages
132+ ### Flow control interactions while sending & receiving messages
133133
134- ###Flow control and buffer pool : Control API
134+ ### Flow control and buffer pool : Control API
135135
136- ###Bi Directional Streaming : Client-side code
136+ ### Bi Directional Streaming : Client-side code
137137
138138 var done = NSCondition()
139139 let updateCall = try service.update()
@@ -167,7 +167,7 @@ The plugin is called from `protoc` and can be invoked for `echo.proto` like this
167167 done.wait()
168168 done.unlock()
169169
170- ###Bi Directional Streaming : Server-side code
170+ ### Bi Directional Streaming : Server-side code
171171
172172 // update streams back messages as they are received in an input stream.
173173 func update(session : Echo_EchoUpdateSession) throws -> Void {
@@ -186,4 +186,4 @@ The plugin is called from `protoc` and can be invoked for `echo.proto` like this
186186 try session.Close()
187187 }
188188
189- ###Any stub deletion/cleanup code needed
189+ ### Any stub deletion/cleanup code needed
0 commit comments