forked from grpc/grpc-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.grpc.swift
72 lines (63 loc) · 2.45 KB
/
test.grpc.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the protocol buffer compiler.
// Source: test.proto
//
//
// Copyright 2018, gRPC Authors All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import GRPC
import NIO
import SwiftProtobuf
internal final class Codegentest_FooTestClient: Codegentest_FooClientProtocol {
private let fakeChannel: FakeChannel
internal var defaultCallOptions: CallOptions
internal var interceptors: Codegentest_FooClientInterceptorFactoryProtocol?
internal var channel: GRPCChannel {
return self.fakeChannel
}
internal init(
fakeChannel: FakeChannel = FakeChannel(),
defaultCallOptions callOptions: CallOptions = CallOptions(),
interceptors: Codegentest_FooClientInterceptorFactoryProtocol? = nil
) {
self.fakeChannel = fakeChannel
self.defaultCallOptions = callOptions
self.interceptors = interceptors
}
/// Make a unary response for the Bar RPC. This must be called
/// before calling 'bar'. See also 'FakeUnaryResponse'.
///
/// - Parameter requestHandler: a handler for request parts sent by the RPC.
internal func makeBarResponseStream(
_ requestHandler: @escaping (FakeRequestPart<Codegentest_BarRequest>) -> () = { _ in }
) -> FakeUnaryResponse<Codegentest_BarRequest, Codegentest_BarResponse> {
return self.fakeChannel.makeFakeUnaryResponse(path: "/codegentest.Foo/Bar", requestHandler: requestHandler)
}
internal func enqueueBarResponse(
_ response: Codegentest_BarResponse,
_ requestHandler: @escaping (FakeRequestPart<Codegentest_BarRequest>) -> () = { _ in }
) {
let stream = self.makeBarResponseStream(requestHandler)
// This is the only operation on the stream; try! is fine.
try! stream.sendMessage(response)
}
/// Returns true if there are response streams enqueued for 'Bar'
internal var hasBarResponsesRemaining: Bool {
return self.fakeChannel.hasFakeResponseEnqueued(forPath: "/codegentest.Foo/Bar")
}
}