io.grpc.protobuf.lite.ProtoLiteUtils Java Examples
The following examples show how to use
io.grpc.protobuf.lite.ProtoLiteUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GrpcClient.java From JavaInterview with Apache License 2.0 | 6 votes |
public void greet() throws IOException { GreeterOuterClass.Request request = GreeterOuterClass.Request .newBuilder() .setName("aaa") .build(); try { GreeterOuterClass.Response response = this.blockingStub.hello(request); System.out.println(response.getMsg()); } catch (StatusRuntimeException e){ System.out.println(e.toString()); System.out.println(e.getStatus().getCode()); Metadata metadata = e.getTrailers(); com.google.rpc.Status status = metadata.get(Metadata.Key.of("grpc-status-details-bin", ProtoLiteUtils.metadataMarshaller(com.google.rpc.Status.getDefaultInstance()))); if(status.getDetailsCount() > 0){ Any any = status.getDetails(0); GreeterOuterClass.Request req = any.unpack(GreeterOuterClass.Request.class); System.out.println(req.getName()); } } }
Example #2
Source File: ProtoUtils.java From grpc-nebula-java with Apache License 2.0 | 2 votes |
/** * Sets the global registry for proto marshalling shared across all servers and clients. * * <p>Warning: This API will likely change over time. It is not possible to have separate * registries per Process, Server, Channel, Service, or Method. This is intentional until there * is a more appropriate API to set them. * * <p>Warning: Do NOT modify the extension registry after setting it. It is thread safe to call * {@link #setExtensionRegistry}, but not to modify the underlying object. * * <p>If you need custom parsing behavior for protos, you will need to make your own * {@code MethodDescriptor.Marshaller} for the time being. * * @since 1.16.0 */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1787") public static void setExtensionRegistry(ExtensionRegistry registry) { ProtoLiteUtils.setExtensionRegistry(registry); }
Example #3
Source File: ProtoUtils.java From grpc-nebula-java with Apache License 2.0 | 2 votes |
/** * Create a {@link Marshaller} for protos of the same type as {@code defaultInstance}. * * @since 1.0.0 */ public static <T extends Message> Marshaller<T> marshaller(final T defaultInstance) { return ProtoLiteUtils.marshaller(defaultInstance); }
Example #4
Source File: ProtoUtils.java From grpc-nebula-java with Apache License 2.0 | 2 votes |
/** * Produce a metadata marshaller for a protobuf type. * * @since 1.13.0 */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4477") public static <T extends Message> Metadata.BinaryMarshaller<T> metadataMarshaller(T instance) { return ProtoLiteUtils.metadataMarshaller(instance); }
Example #5
Source File: ProtoUtils.java From grpc-java with Apache License 2.0 | 2 votes |
/** * Sets the global registry for proto marshalling shared across all servers and clients. * * <p>Warning: This API will likely change over time. It is not possible to have separate * registries per Process, Server, Channel, Service, or Method. This is intentional until there * is a more appropriate API to set them. * * <p>Warning: Do NOT modify the extension registry after setting it. It is thread safe to call * {@link #setExtensionRegistry}, but not to modify the underlying object. * * <p>If you need custom parsing behavior for protos, you will need to make your own * {@code MethodDescriptor.Marshaller} for the time being. * * @since 1.16.0 */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/1787") public static void setExtensionRegistry(ExtensionRegistry registry) { ProtoLiteUtils.setExtensionRegistry(registry); }
Example #6
Source File: ProtoUtils.java From grpc-java with Apache License 2.0 | 2 votes |
/** * Create a {@link Marshaller} for protos of the same type as {@code defaultInstance}. * * @since 1.0.0 */ public static <T extends Message> Marshaller<T> marshaller(final T defaultInstance) { return ProtoLiteUtils.marshaller(defaultInstance); }
Example #7
Source File: ProtoUtils.java From grpc-java with Apache License 2.0 | 2 votes |
/** * Produce a metadata marshaller for a protobuf type. * * @since 1.13.0 */ @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4477") public static <T extends Message> Metadata.BinaryMarshaller<T> metadataMarshaller(T instance) { return ProtoLiteUtils.metadataMarshaller(instance); }