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

Add service descriptor to code generator #616

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

Gorzen
Copy link
Contributor

@Gorzen Gorzen commented Apr 6, 2023

This PR adds service descriptor in the code generator for gRPC services.

The service descriptor is useful to get general information about the service. For instance, in our case, we use the name to load the service's configuration.

.call(serviceClient)
.newline
.call(serviceBinding)
.outdent
.newline
.add("}")

private[this] def serviceDescriptor: PrinterEndo = {
_.add(s"def serviceDescriptor: ${Fs2GrpcServicePrinter.constants.ServiceDescriptor} = ${service.grpcDescriptor.fullName}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ${Fs2GrpcServicePrinter.constants.ServiceDescriptor} is to avoid conflicts with import com.google.protobuf.Descriptors.{MethodDescriptor, ServiceDescriptor}

@Gorzen Gorzen force-pushed the add-service-descriptor branch 2 times, most recently from d451399 to 8b9e0e0 Compare April 6, 2023 14:32
@Gorzen Gorzen force-pushed the add-service-descriptor branch 2 times, most recently from d451399 to 8b9e0e0 Compare April 11, 2023 09:32
@lomigmegard
Copy link

Hi @ahjohannessen ,

Would you have time to have a look at this PR? It exposes the service descriptor to the generated gRPC service companion objects.

There could be alternative implementation or naming, but the core idea of linking the GeneratedCompanion to its corresponding descriptor (Java or ScalaPB one) would be very useful to build generic tooling around.

@Gorzen Gorzen force-pushed the add-service-descriptor branch from 8b9e0e0 to 8607cdf Compare September 2, 2024 14:53
@ahjohannessen
Copy link
Collaborator

ahjohannessen commented Sep 2, 2024

please fix mima by adding ProblemFilters.exclude[ReversedMissingMethodProblem]("fs2.grpc.GeneratedCompanion.serviceDescriptor") to build.sbt

@Gorzen Gorzen force-pushed the add-service-descriptor branch from 8607cdf to ab4831b Compare September 2, 2024 15:13
@ahjohannessen ahjohannessen merged commit 4dd73e6 into typelevel:main Sep 2, 2024
5 checks passed
@Gorzen
Copy link
Contributor Author

Gorzen commented Sep 2, 2024

Thank you! @ahjohannessen

@ahjohannessen
Copy link
Collaborator

@Gorzen np - I have made a new release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants