Skip to content

Commit bde341f

Browse files
authored
Removing precompile due to variability in networking conditions + privacy concerns (#93)
1 parent 8176e94 commit bde341f

File tree

1 file changed

+0
-102
lines changed

1 file changed

+0
-102
lines changed

src/gRPCClient.jl

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -111,106 +111,4 @@ export gRPCAsyncChannelResponse
111111
export gRPCException
112112
export gRPCServiceCallException
113113

114-
115-
@setup_workload begin
116-
function _get_precompile_host()
117-
if "GRPC_PRECOMPILE_SERVER_HOST" in keys(ENV)
118-
ENV["GRPC_PRECOMPILE_SERVER_HOST"]
119-
else
120-
# We don't have a Julia gRPC server so call my Linode's public gRPC endpoint
121-
"172.238.177.88"
122-
end
123-
end
124-
125-
function _get_precompile_port()
126-
if "GRPC_PRECOMPILE_SERVER_PORT" in keys(ENV)
127-
parse(UInt16, ENV["GRPC_PRECOMPILE_SERVER_PORT"])
128-
else
129-
8001
130-
end
131-
end
132-
133-
TEST_HOST = _get_precompile_host()
134-
TEST_PORT = _get_precompile_port()
135-
136-
@compile_workload begin
137-
"GRPC_PRECOMPILE_DISABLE" in keys(ENV) && return
138-
139-
include("../test/gen/test/test_pb.jl")
140-
141-
# Initialize the gRPC package - grpc_shutdown() does the opposite for use with Revise.
142-
grpc_init()
143-
144-
# Unary
145-
client_unary = TestService_TestRPC_Client(TEST_HOST, TEST_PORT)
146-
147-
try
148-
# Sync API
149-
test_response =
150-
grpc_sync_request(client_unary, TestRequest(1, Vector{UInt64}()))
151-
152-
# Async API
153-
request = grpc_async_request(client_unary, TestRequest(1, Vector{UInt64}()))
154-
test_response = grpc_async_await(client_unary, request)
155-
156-
# Streaming
157-
@static if VERSION >= v"1.12"
158-
159-
# Request
160-
client_request =
161-
TestService_TestClientStreamRPC_Client(TEST_HOST, TEST_PORT)
162-
request_c = Channel{TestRequest}(16)
163-
put!(request_c, TestRequest(1, zeros(UInt64, 1)))
164-
close(request_c)
165-
test_response = grpc_async_await(
166-
client_request,
167-
grpc_async_request(client_request, request_c),
168-
)
169-
170-
# Response
171-
client_response =
172-
TestService_TestServerStreamRPC_Client(TEST_HOST, TEST_PORT)
173-
response_c = Channel{TestResponse}(16)
174-
req = grpc_async_request(
175-
client_response,
176-
TestRequest(1, zeros(UInt64, 1)),
177-
response_c,
178-
)
179-
test_response = take!(response_c)
180-
grpc_async_await(req)
181-
182-
# Bidirectional
183-
client_bidirectional =
184-
TestService_TestBidirectionalStreamRPC_Client(TEST_HOST, TEST_PORT)
185-
request_c = Channel{TestRequest}(16)
186-
response_c = Channel{TestResponse}(16)
187-
put!(request_c, TestRequest(1, zeros(UInt64, 1)))
188-
req = grpc_async_request(client_bidirectional, request_c, response_c)
189-
test_response = take!(response_c)
190-
close(request_c)
191-
grpc_async_await(req)
192-
end
193-
catch ex
194-
if !(isa(ex, gRPCServiceCallException) && ex.grpc_status == GRPC_DEADLINE_EXCEEDED)
195-
rethrow(ex)
196-
end
197-
198-
@warn """
199-
DEADLINE_EXCEEDED during gRPCClient.jl precompile
200-
201-
A dedicated server for allowing this package to precompile is provided to the public but is not accessible from this network.
202-
If you care about this you can consider the following options:
203-
- Request that your network administrator allow connections to this address on TCP: $(TEST_HOST):$(TEST_PORT)
204-
- Add a precompile block to your own package which calls an accessible gRPC server
205-
- Run your own instance of the Go gRPC test server in public mode `./grpc_test_server -public` and set GRPC_PRECOMPILE_SERVER_HOST and GRPC_PRECOMPILE_SERVER_PORT environment variables to point to it
206-
- Set the GRPC_PRECOMPILE_DISABLE environment variable to disable gRPCClient.jl precompiliation and this message
207-
"""
208-
end
209-
210-
grpc_shutdown()
211-
end
212-
end
213-
214-
215-
216114
end

0 commit comments

Comments
 (0)