forked from LesnyRumcajs/grpc_bench
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add d bench - wip * use a working D image * Update Co-authored-by: Trisfald <[email protected]>
- Loading branch information
Showing
7 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
FROM dlang2/ldc-ubuntu:1.26.0 | ||
|
||
RUN apt update && apt install -y protobuf-compiler git cmake g++ | ||
|
||
WORKDIR /app | ||
RUN git clone --depth 1 --branch master --recurse-submodules https://github.com/huntlabs/grpc-dlang | ||
WORKDIR /app/grpc-dlang | ||
# Building the protocol buffer compiler for D | ||
RUN dub build protobuf:protoc-gen-d | ||
# Building the gRPC plugin for D | ||
WORKDIR /app/grpc-dlang/compiler | ||
RUN mkdir build | ||
WORKDIR /app/grpc-dlang/compiler/build | ||
RUN cmake .. && make -j4 | ||
RUN cp deps/protobuf/protoc* /usr/local/bin | ||
RUN cp grpc_dlang_plugin /usr/local/bin | ||
# Building the core library | ||
WORKDIR /app/grpc-dlang | ||
RUN dub build | ||
|
||
COPY proto /app/proto | ||
COPY d_grpc_bench /app | ||
WORKDIR /app | ||
RUN protoc --plugin=$(find / -name 'protoc-gen-d' -type f | head -n 1) --d_out=/app/source --proto_path=/app/proto/helloworld helloworld.proto | ||
RUN protoc --plugin=protoc-gen-grpc=/usr/local/bin/grpc_dlang_plugin --grpc_out=/app/source/helloworld --proto_path=/app/proto/helloworld helloworld.proto | ||
|
||
RUN dub build -b release | ||
|
||
ENTRYPOINT [ "/app/server" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "server", | ||
"description": "A simple example for gRPC.", | ||
"license": "MIT", | ||
"targetType": "executable", | ||
"dependencies": { | ||
"grpc" :{"path": "grpc-dlang"} | ||
}, | ||
"dflags-ldc": ["-flto=full"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"fileVersion": 1, | ||
"versions": { | ||
"grpc": {"path":"grpc-dlang"}, | ||
"hunt": "1.7.15", | ||
"hunt-extra": "1.2.3", | ||
"hunt-http": "0.8.1", | ||
"hunt-net": "0.7.1", | ||
"hunt-openssl": "1.0.5", | ||
"protobuf": "0.6.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module GreeterImpl; | ||
|
||
import helloworld.helloworld; | ||
import helloworld.helloworldRpc; | ||
import grpc; | ||
|
||
/** | ||
* | ||
*/ | ||
class GreeterImpl : GreeterBase { | ||
override Status SayHello(HelloRequest request, ref HelloReply reply) { | ||
reply.response = request.request; | ||
return Status.OK; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module server; | ||
|
||
import GreeterImpl; | ||
import grpc; | ||
import hunt.logging; | ||
import std.stdio; | ||
|
||
void main() | ||
{ | ||
string host = "0.0.0.0"; | ||
ushort port = 50051; | ||
|
||
GrpcServer server = new GrpcServer(); | ||
server.listen(host , port); | ||
server.register(new GreeterImpl.GreeterImpl()); | ||
server.start(); | ||
|
||
writeln("Server started on ", host, ":", port); | ||
|
||
getchar(); | ||
} |