dapr / go-sdk

Dapr SDK for go
Apache License 2.0
446 stars 171 forks source link

Allow setting own gRPC server when calling `NewService` #400

Closed pimmerks closed 1 year ago

pimmerks commented 1 year ago

We are building an application that exposes it's own gRPC service, it also needs to subscribe to the dapr pub/sub component.

Currently we are allowed to set the listener, but this is not enough, as we found that about half of the time, our own gRPC server responds, and the other half of the time the dapr service responds with an unknown service xxx.xxx.

If this is merged, the user is allowed to set their own grpcServer with the NewServiceWithGrpcServer() func.

In action:

lis, _ := net.Listen("tcp", "localhost:8080")
server := grpc.NewServer()

// Register dapr
dapr.NewServiceWithGrpcServer(lis, server)

// Setup dapr subscriptions here

// Register own services
proto.RegisterOwnServer1(server, ownServer1{})
proto.RegisterOwnServer2(server, ownServer2{})

go server.Serve(lis)

In issue https://github.com/dapr/go-sdk/issues/237 the same problem has been found.

codecov[bot] commented 1 year ago

Codecov Report

Merging #400 (4f65fbd) into main (f6dccfd) will increase coverage by 0.05%. The diff coverage is 90.90%.

@@            Coverage Diff             @@
##             main     #400      +/-   ##
==========================================
+ Coverage   68.93%   68.98%   +0.05%     
==========================================
  Files          31       31              
  Lines        2479     2483       +4     
==========================================
+ Hits         1709     1713       +4     
  Misses        676      676              
  Partials       94       94              
Impacted Files Coverage Δ
service/grpc/service.go 59.64% <90.90%> (+3.04%) :arrow_up:
yaron2 commented 1 year ago

Thanks for this contribution @pimmerks