use of io.helidon.grpc.server.ServiceDescriptor in project helidon by oracle.
the class GrpcMetricsInterceptorIT method shouldHaveCorrectNameWithDotsForSlashes.
@Test
public void shouldHaveCorrectNameWithDotsForSlashes() throws Exception {
ServiceDescriptor descriptor = ServiceDescriptor.builder(createMockService()).name("My/Service").unary("bar", this::dummyUnary).build();
MethodDescriptor methodDescriptor = descriptor.method("bar");
GrpcMetrics metrics = GrpcMetrics.counted();
ServerCall<String, String> call = call(metrics, descriptor, methodDescriptor);
call.close(Status.OK, new Metadata());
Counter appCounter = appRegistry.get().counter("My.Service.bar");
assertVendorMetrics();
assertThat(appCounter.getCount(), is(1L));
}
use of io.helidon.grpc.server.ServiceDescriptor in project helidon by oracle.
the class GrpcMetricsInterceptorIT method shouldApplyDescription.
@Test
public void shouldApplyDescription() throws Exception {
ServiceDescriptor descriptor = ServiceDescriptor.builder(createMockService()).unary("barDesc", this::dummyUnary).build();
MethodDescriptor methodDescriptor = descriptor.method("barDesc");
GrpcMetrics metrics = GrpcMetrics.counted().description("foo");
ServerCall<String, String> call = call(metrics, methodDescriptor);
call.close(Status.OK, new Metadata());
Counter appCounter = appRegistry.get().counter("Foo.barDesc");
assertVendorMetrics();
assertThat(appCounter.toString(), containsString("description='foo'"));
}
use of io.helidon.grpc.server.ServiceDescriptor in project helidon by oracle.
the class GrpcServiceBuilderTest method shouldCreateServiceWithMethodNamesFromAnnotation.
@Test
public void shouldCreateServiceWithMethodNamesFromAnnotation() {
ServiceTwo service = new ServiceTwo();
GrpcServiceBuilder builder = GrpcServiceBuilder.create(service, beanManager);
ServiceDescriptor descriptor = builder.build();
assertThat(descriptor.name(), is("ServiceTwo"));
assertThat(descriptor.methods().size(), is(4));
MethodDescriptor methodDescriptor;
io.grpc.MethodDescriptor grpcDescriptor;
methodDescriptor = descriptor.method("One");
assertThat(methodDescriptor, is(notNullValue()));
assertThat(methodDescriptor.name(), is("One"));
assertThat(methodDescriptor.callHandler(), is(notNullValue()));
grpcDescriptor = methodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceTwo/One"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.UNARY));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
methodDescriptor = descriptor.method("Two");
assertThat(methodDescriptor, is(notNullValue()));
assertThat(methodDescriptor.name(), is("Two"));
assertThat(methodDescriptor.callHandler(), is(notNullValue()));
grpcDescriptor = methodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceTwo/Two"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
methodDescriptor = descriptor.method("Three");
assertThat(methodDescriptor, is(notNullValue()));
assertThat(methodDescriptor.name(), is("Three"));
assertThat(methodDescriptor.callHandler(), is(notNullValue()));
grpcDescriptor = methodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceTwo/Three"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
methodDescriptor = descriptor.method("Four");
assertThat(methodDescriptor, is(notNullValue()));
assertThat(methodDescriptor.name(), is("Four"));
assertThat(methodDescriptor.callHandler(), is(notNullValue()));
grpcDescriptor = methodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceTwo/Four"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
}
use of io.helidon.grpc.server.ServiceDescriptor in project helidon by oracle.
the class GrpcServiceBuilderTest method assertServiceOne.
public void assertServiceOne(GrpcServiceBuilder builder) {
ServiceDescriptor descriptor = builder.build();
assertThat(descriptor.name(), is("ServiceOne/foo"));
assertThat(descriptor.methods().size(), is(4));
MethodDescriptor methodDescriptor;
io.grpc.MethodDescriptor grpcDescriptor;
methodDescriptor = descriptor.method("unary");
assertThat(methodDescriptor, is(notNullValue()));
assertThat(methodDescriptor.name(), is("unary"));
assertThat(methodDescriptor.callHandler(), is(notNullValue()));
grpcDescriptor = methodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceOne/foo/unary"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.UNARY));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
methodDescriptor = descriptor.method("clientStreaming");
assertThat(methodDescriptor, is(notNullValue()));
assertThat(methodDescriptor.name(), is("clientStreaming"));
assertThat(methodDescriptor.callHandler(), is(notNullValue()));
grpcDescriptor = methodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceOne/foo/clientStreaming"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
methodDescriptor = descriptor.method("serverStreaming");
assertThat(methodDescriptor, is(notNullValue()));
assertThat(methodDescriptor.name(), is("serverStreaming"));
assertThat(methodDescriptor.callHandler(), is(notNullValue()));
grpcDescriptor = methodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceOne/foo/serverStreaming"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
methodDescriptor = descriptor.method("bidiStreaming");
assertThat(methodDescriptor, is(notNullValue()));
assertThat(methodDescriptor.name(), is("bidiStreaming"));
assertThat(methodDescriptor.callHandler(), is(notNullValue()));
grpcDescriptor = methodDescriptor.descriptor();
assertThat(grpcDescriptor, is(notNullValue()));
assertThat(grpcDescriptor.getFullMethodName(), is("ServiceOne/foo/bidiStreaming"));
assertThat(grpcDescriptor.getType(), is(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING));
assertThat(grpcDescriptor.getRequestMarshaller(), is(instanceOf(JavaMarshaller.class)));
assertThat(grpcDescriptor.getResponseMarshaller(), is(instanceOf(JavaMarshaller.class)));
}
use of io.helidon.grpc.server.ServiceDescriptor in project helidon by oracle.
the class GrpcServiceBuilderTest method shouldUseServiceNameFromAnnotation.
@Test
public void shouldUseServiceNameFromAnnotation() {
ServiceOne service = new ServiceOne();
GrpcServiceBuilder modeller = GrpcServiceBuilder.create(service, beanManager);
ServiceDescriptor descriptor = modeller.build();
assertThat(descriptor.name(), is("ServiceOne/foo"));
}
Aggregations