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

Suggested changes for supporting OSGi Remote Services #6980

Closed
wants to merge 6 commits into from

Conversation

scottslewis
Copy link

@scottslewis scottslewis commented Apr 25, 2020

Added methods in java_generator.h/.cpp for generating two new types:

GenerateOSGiService - Generates interface class(s) (in java_package
directory) that has the same name as the rpc declaration in the
protofile. For example:

service HealthCheck {
  rpc check(HealthCheckRequest) returns (HealthCheckResponse);
}

along with all the other classes normally generated by grcp plugin it would generate a HealthCheck service interface class:

package io.grpc.health.v1;

public interface HealthCheck {

    public HealthCheckResponse check(HealthCheckRequest request);

}

Note that only blocking method calls (not streaming) are included in the
interface.

GenerateOSGiAbstractImplService generates an abstract impl class that
implements the (e.g.) HealthCheck interface, with naming convention
AbstractImpl:

package io.grpc.health.v1;

import io.grpc.stub.StreamObserver;

public abstract class AbstractHealthCheckImpl extends
HealthCheckGrpc.HealthCheckImplBase implements HealthCheck {

    public abstract HealthCheckResponse check(HealthCheckRequest
request);

    public void check(HealthCheckRequest request,
StreamObserver<HealthCheckResponse> responseObserver) {
        responseObserver.onNext(check(request));
        responseObserver.onCompleted();
    }
}

Note that the impl of the grcp check/2 method calls the service
interface method check/1.

With the service interface method and the abstract service impl class,
it is easy for a remote service to be created as all that is needed is
to provide implementation for check/1 method in subclass. Consumers of
the remote service use the interface only.

methods in java_generator.h/.cpp for generating two new types:

GenerateOSGiService - Generates interface class(s) (in java_package
directory) that has the same name as the rpc declaration in the
protofile.  For example:

service HealthCheck {
  // If the requested service is unknown, the call will fail with status
  // NOT_FOUND.
  rpc check(HealthCheckRequest) returns (HealthCheckResponse);
}

would generate a HealthCheck service interface class:

package io.grpc.health.v1;

public interface HealthCheck {

    public HealthCheckResponse check(HealthCheckRequest request);

}

Note that only blocking method calls (not streaming) are included in the
interface declaration.

GenerateOSGiAbstractImplService generates an abstract impl class that
implements the (e.g.) HealthCheck interface, with naming convention
Abstract<service name>Impl:

package io.grpc.health.v1;

import io.grpc.stub.StreamObserver;

public abstract class AbstractHealthCheckImpl extends
HealthCheckGrpc.HealthCheckImplBase implements HealthCheck {

    public abstract HealthCheckResponse check(HealthCheckRequest
request);

    public void check(HealthCheckRequest request,
StreamObserver<HealthCheckResponse> responseObserver) {
        responseObserver.onNext(check(request));
        responseObserver.onCompleted();
    }
}

Note that the impl of the grcp check/2 method calls the service
interface method check/1.

With the service interface method and the abstract service impl class,
it is easy for a remote service to be created as all that is needed is
to provide implementation for check/1 method in subclass.  Consumers of
the remote service use the interface only.
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 25, 2020

CLA Check
The committers are authorized under a signed CLA.

@scottslewis scottslewis changed the title Initial suggested changes for supporting OSGi Remote Services Suggested changes for supporting OSGi Remote Services Apr 27, 2020
@scottslewis
Copy link
Author

These grpc-java protobuf plugin changes result in two new java classes: and Interface class (with suffix Intf) and an abstract impl of this interface: AbstractIntfImlpl.

Frome what I can tell the travice continuous integration build above fails on tests because of these git errors associated with the new java files created by the modified plugin:

https://travis-ci.org/github/grpc/grpc-java/jobs/679881915

$ test -z "$(git status --porcelain)" || (git status && echo Error Working directory is not clean. Forget to commit generated files? && false)

HEAD detached at FETCH_HEAD

Untracked files:

(use "git add ..." to include in what will be committed)

alts/src/generated/main/grpc/io/grpc/alts/internal/AbstractHandshakerServiceImpl.java

alts/src/generated/main/grpc/io/grpc/alts/internal/HandshakerServiceIntf.java

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/AbstractBenchmarkServiceImpl.java

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/AbstractReportQpsScenarioServiceImpl.java

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/AbstractWorkerServiceImpl.java

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/BenchmarkServiceIntf.java

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/ReportQpsScenarioServiceIntf.java

benchmarks/src/generated/main/grpc/io/grpc/benchmarks/proto/WorkerServiceIntf.java

grpclb/src/generated/main/grpc/io/grpc/lb/v1/AbstractLoadBalancerImpl.java

grpclb/src/generated/main/grpc/io/grpc/lb/v1/LoadBalancerIntf.java

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/AbstractLoadBalancerStatsServiceImpl.java

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/AbstractMetricsServiceImpl.java

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/AbstractReconnectServiceImpl.java

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/AbstractTestServiceImpl.java

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/AbstractUnimplementedServiceImpl.java

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/LoadBalancerStatsServiceIntf.java

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/MetricsServiceIntf.java

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/ReconnectServiceIntf.java

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/TestServiceIntf.java

interop-testing/src/generated/main/grpc/io/grpc/testing/integration/UnimplementedServiceIntf.java

rls/src/generated/main/grpc/io/grpc/lookup/v1/AbstractRouteLookupServiceImpl.java

rls/src/generated/main/grpc/io/grpc/lookup/v1/RouteLookupServiceIntf.java

services/src/generated/main/grpc/io/grpc/channelz/v1/AbstractChannelzImpl.java

services/src/generated/main/grpc/io/grpc/channelz/v1/ChannelzIntf.java

services/src/generated/main/grpc/io/grpc/health/v1/AbstractHealthImpl.java

services/src/generated/main/grpc/io/grpc/health/v1/HealthIntf.java

services/src/generated/main/grpc/io/grpc/reflection/v1alpha/AbstractServerReflectionImpl.java

services/src/generated/main/grpc/io/grpc/reflection/v1alpha/ServerReflectionIntf.java

testing-proto/src/generated/main/grpc/io/grpc/testing/protobuf/AbstractSimpleServiceImpl.java

testing-proto/src/generated/main/grpc/io/grpc/testing/protobuf/SimpleServiceIntf.java

xds/src/generated/main/grpc/com/github/udpa/udpa/service/orca/v1/AbstractOpenRcaServiceImpl.java

xds/src/generated/main/grpc/com/github/udpa/udpa/service/orca/v1/OpenRcaServiceIntf.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/AbstractClusterDiscoveryServiceImpl.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/AbstractEndpointDiscoveryServiceImpl.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/AbstractListenerDiscoveryServiceImpl.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/AbstractRouteDiscoveryServiceImpl.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/AbstractScopedRoutesDiscoveryServiceImpl.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/AbstractVirtualHostDiscoveryServiceImpl.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/ClusterDiscoveryServiceIntf.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/EndpointDiscoveryServiceIntf.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/ListenerDiscoveryServiceIntf.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/RouteDiscoveryServiceIntf.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/ScopedRoutesDiscoveryServiceIntf.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/api/v2/VirtualHostDiscoveryServiceIntf.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/service/discovery/v2/AbstractAggregatedDiscoveryServiceImpl.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/service/discovery/v2/AbstractSecretDiscoveryServiceImpl.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/service/discovery/v2/AggregatedDiscoveryServiceIntf.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/service/discovery/v2/SecretDiscoveryServiceIntf.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/service/load_stats/v2/AbstractLoadReportingServiceImpl.java

xds/src/generated/main/grpc/io/envoyproxy/envoy/service/load_stats/v2/LoadReportingServiceIntf.java

nothing added to commit but untracked files present (use "git add" to track)

Error Working directory is not clean. Forget to commit generated files?

The command "test -z "$(git status --porcelain)" || (git status && echo Error Working directory is not clean. Forget to commit generated files? && false)" failed and exited with 1 during .

Your build has been stopped.

@ejona86
Copy link
Member

ejona86 commented May 4, 2020

This was discussed in #6981, and we weren't ready to have interfaces in our generated code. @scottslewis split this out into a separate plugin at https://github.com/ECF/grpc-osgi-generator

@ejona86 ejona86 closed this May 4, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants