-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-client.lua
More file actions
44 lines (37 loc) · 957 Bytes
/
test-client.lua
File metadata and controls
44 lines (37 loc) · 957 Bytes
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
require "utils"
local cf = require "cf"
local client = require "lua-grpc.client"
local gclient = client:new { domain = "http://localhost/", max = 1 }
gclient:load([[
syntax = "proto3";
service Greeter {
rpc SayHello(HelloRequest) returns (HelloReply);
rpc SayHelloAgain(HelloRequest) returns (HelloReply);
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}
]])
cf.fork(function ()
while true do
local info, err = gclient:call("Greeter", "SayHello", { name = "車先生" })
if not info then
return print(false, err)
end
var_dump(info)
cf.sleep(math.random())
end
end)
cf.fork(function ()
while true do
local info, err = gclient:call("Greeter", "SayHelloAgain", { name = "車爪鱼" })
if not info then
return print(false, err)
end
var_dump(info)
cf.sleep(math.random())
end
end)