Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tag 1.0 with ProtoBuf pinned to working version #39

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} - experimental ${{ matrix.experimental }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
Expand Down Expand Up @@ -46,11 +46,11 @@ jobs:
experimental: false
steps:
- uses: actions/checkout@v2
- name: setup protoc
uses: arduino/setup-protoc@v1
with:
version: '3.x'
- run: protoc --version
# - name: setup protoc
# uses: arduino/setup-protoc@v1
# with:
# version: '3.x'
# - run: protoc --version
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
Expand All @@ -66,6 +66,8 @@ jobs:
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- name: Install ProtoBuf For Code Generation
run: julia -e 'using Pkg; Pkg.add([Pkg.PackageSpec(;name="ProtoBuf", version="0.11.5"), Pkg.PackageSpec(;name="protoc_jll")]); Pkg.instantiate(); Pkg.build();'
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "gRPCClient"
uuid = "aaca4a50-36af-4a1d-b878-4c443f2061ad"
authors = ["Tanmay K.M. <[email protected]>"]
version = "0.1.4"
version = "1.0.0"

[deps]
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
Expand All @@ -11,7 +11,7 @@ ProtoBuf = "3349acd9-ac6a-5e09-bcdb-63829b23a429"
[compat]
Downloads = "1.4"
LibCURL = "0.6"
ProtoBuf = "0.11"
ProtoBuf = "~0.11"
julia = "1.6"

[extras]
Expand Down
21 changes: 19 additions & 2 deletions src/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ function get_generated_method_table(s::String)
T
end

# Defining a local protoc to avoid issues with ProtoBuf.protoc,
# wherein it was using the form `protoc_jll.protoc() do .. end`
# which is now deprecated and is causing errors in code generation.
function grpc_protoc(args=``; protoc_path=ProtoBuf.protoc_jll.protoc())
plugin_dir = abspath(joinpath(dirname(pathof(ProtoBuf)), "..", "plugin"))
plugin = joinpath(plugin_dir, Sys.iswindows() ? "protoc-gen-julia_win.bat" : "protoc-gen-julia")

ENV′ = copy(ENV)
ENV′["PATH"] = string(plugin_dir, Sys.iswindows() ? ";" : ":", ENV′["PATH"])
ENV′["JULIA"] = joinpath(Sys.BINDIR, Base.julia_exename())
# protobuf plugin uses COVERAGE env var to pass coverage flag to julia
# we do not want to pass unintended values that sometimes CI environments set
# we also do not intend to trigger coverage in the plugin while running CI in this package
ENV′["COVERAGE"] = ""
run(setenv(`$protoc_path --plugin=protoc-gen-julia=$plugin $args`, ENV′))
end

"""
generate(proto::String; outdir::String=pwd())

Expand All @@ -127,7 +144,7 @@ Generate a gRPC client from protobuf specification file.
- `outdir`: Directory to write generated code into, created if not present
already. Existing files if any will be overwtitten.
"""
function generate(proto::String; outdir::String=pwd(), includes::Vector{String}=String[])
function generate(proto::String; outdir::String=pwd(), includes::Vector{String}=String[], protoc_path=ProtoBuf.protoc_jll.protoc())
if !isfile(proto)
throw(ArgumentError("No such file - $proto"))
end
Expand All @@ -149,7 +166,7 @@ function generate(proto::String; outdir::String=pwd(), includes::Vector{String}=
bindir = Sys.BINDIR
pathenv = string(ENV["PATH"], Sys.iswindows() ? ";" : ":", bindir)
withenv("PATH"=>pathenv) do
ProtoBuf.protoc(`$includeflag --julia_out=$outdir $proto`)
grpc_protoc(`$includeflag --julia_out=$outdir $proto`; protoc_path=protoc_path)
end

# include the generated code and detect service method names
Expand Down
3 changes: 2 additions & 1 deletion src/grpc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ function call_method(channel::gRPCChannel, service::ServiceDescriptor, method::M
catch ex
gRPCCheck(status_future) # check for core issue
if isa(ex, InvalidStateException)
throw(gRPCServiceCallException("Server closed connection without any response"))
status = gRPCStatus(status_future)
throw(gRPCServiceCallException(status.grpc_status, "Server closed connection without any response"))
else
rethrow() # throw this error if there's no other issue
end
Expand Down
Loading