parent
d4dcbee4c9
commit
6c416c2818
6 changed files with 721 additions and 3 deletions
|
|
@ -57,7 +57,7 @@ you would need to reference it as `Wrapper$Message` instead of `Wrapper.Message`
|
|||
@@@
|
||||
|
||||
Akka provides serializers for several primitive types and [protobuf](http://code.google.com/p/protobuf/)
|
||||
`com.google.protobuf.GeneratedMessage` by default (the latter only if
|
||||
`com.google.protobuf.GeneratedMessage` (protobuf2) and `com.google.protobuf.GeneratedMessageV3` (protobuf3) by default (the latter only if
|
||||
depending on the akka-remote module), so normally you don't need to add
|
||||
configuration for that if you send raw protobuf messages as actor messages.
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ akka {
|
|||
# This com.google.protobuf serialization binding is only used if the class can be loaded,
|
||||
# i.e. com.google.protobuf dependency has been added in the application project.
|
||||
"com.google.protobuf.GeneratedMessage" = proto
|
||||
"com.google.protobuf.GeneratedMessageV3" = proto
|
||||
|
||||
"akka.actor.Identify" = akka-misc
|
||||
"akka.actor.ActorIdentity" = akka-misc
|
||||
|
|
|
|||
|
|
@ -0,0 +1,688 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
// Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
// source: ProtobufProtocolV3.proto
|
||||
|
||||
package akka.remote.protobuf.v3;
|
||||
|
||||
public final class ProtobufProtocolV3 {
|
||||
private ProtobufProtocolV3() {}
|
||||
|
||||
public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {}
|
||||
|
||||
public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) {
|
||||
registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry);
|
||||
}
|
||||
|
||||
public interface MyMessageV3OrBuilder
|
||||
extends
|
||||
// @@protoc_insertion_point(interface_extends:MyMessageV3)
|
||||
com.google.protobuf.MessageOrBuilder {
|
||||
|
||||
/** <code>string query = 1;</code> */
|
||||
java.lang.String getQuery();
|
||||
/** <code>string query = 1;</code> */
|
||||
com.google.protobuf.ByteString getQueryBytes();
|
||||
|
||||
/** <code>int32 page_number = 2;</code> */
|
||||
int getPageNumber();
|
||||
|
||||
/** <code>int32 result_per_page = 3;</code> */
|
||||
int getResultPerPage();
|
||||
}
|
||||
/** Protobuf type {@code MyMessageV3} */
|
||||
public static final class MyMessageV3 extends com.google.protobuf.GeneratedMessageV3
|
||||
implements
|
||||
// @@protoc_insertion_point(message_implements:MyMessageV3)
|
||||
MyMessageV3OrBuilder {
|
||||
private static final long serialVersionUID = 0L;
|
||||
// Use MyMessageV3.newBuilder() to construct.
|
||||
private MyMessageV3(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
private MyMessageV3() {
|
||||
query_ = "";
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
@SuppressWarnings({"unused"})
|
||||
protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
|
||||
return new MyMessageV3();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
|
||||
return this.unknownFields;
|
||||
}
|
||||
|
||||
private MyMessageV3(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
this();
|
||||
if (extensionRegistry == null) {
|
||||
throw new java.lang.NullPointerException();
|
||||
}
|
||||
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
|
||||
com.google.protobuf.UnknownFieldSet.newBuilder();
|
||||
try {
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
int tag = input.readTag();
|
||||
switch (tag) {
|
||||
case 0:
|
||||
done = true;
|
||||
break;
|
||||
case 10:
|
||||
{
|
||||
java.lang.String s = input.readStringRequireUtf8();
|
||||
|
||||
query_ = s;
|
||||
break;
|
||||
}
|
||||
case 16:
|
||||
{
|
||||
pageNumber_ = input.readInt32();
|
||||
break;
|
||||
}
|
||||
case 24:
|
||||
{
|
||||
resultPerPage_ = input.readInt32();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) {
|
||||
done = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
throw e.setUnfinishedMessage(this);
|
||||
} catch (java.io.IOException e) {
|
||||
throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this);
|
||||
} finally {
|
||||
this.unknownFields = unknownFields.build();
|
||||
makeExtensionsImmutable();
|
||||
}
|
||||
}
|
||||
|
||||
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
|
||||
return akka.remote.protobuf.v3.ProtobufProtocolV3.internal_static_MyMessageV3_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return akka.remote.protobuf.v3.ProtobufProtocolV3
|
||||
.internal_static_MyMessageV3_fieldAccessorTable.ensureFieldAccessorsInitialized(
|
||||
akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3.class,
|
||||
akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3.Builder.class);
|
||||
}
|
||||
|
||||
public static final int QUERY_FIELD_NUMBER = 1;
|
||||
private volatile java.lang.Object query_;
|
||||
/** <code>string query = 1;</code> */
|
||||
public java.lang.String getQuery() {
|
||||
java.lang.Object ref = query_;
|
||||
if (ref instanceof java.lang.String) {
|
||||
return (java.lang.String) ref;
|
||||
} else {
|
||||
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
|
||||
java.lang.String s = bs.toStringUtf8();
|
||||
query_ = s;
|
||||
return s;
|
||||
}
|
||||
}
|
||||
/** <code>string query = 1;</code> */
|
||||
public com.google.protobuf.ByteString getQueryBytes() {
|
||||
java.lang.Object ref = query_;
|
||||
if (ref instanceof java.lang.String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
|
||||
query_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
|
||||
public static final int PAGE_NUMBER_FIELD_NUMBER = 2;
|
||||
private int pageNumber_;
|
||||
/** <code>int32 page_number = 2;</code> */
|
||||
public int getPageNumber() {
|
||||
return pageNumber_;
|
||||
}
|
||||
|
||||
public static final int RESULT_PER_PAGE_FIELD_NUMBER = 3;
|
||||
private int resultPerPage_;
|
||||
/** <code>int32 result_per_page = 3;</code> */
|
||||
public int getResultPerPage() {
|
||||
return resultPerPage_;
|
||||
}
|
||||
|
||||
private byte memoizedIsInitialized = -1;
|
||||
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
byte isInitialized = memoizedIsInitialized;
|
||||
if (isInitialized == 1) return true;
|
||||
if (isInitialized == 0) return false;
|
||||
|
||||
memoizedIsInitialized = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
|
||||
if (!getQueryBytes().isEmpty()) {
|
||||
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, query_);
|
||||
}
|
||||
if (pageNumber_ != 0) {
|
||||
output.writeInt32(2, pageNumber_);
|
||||
}
|
||||
if (resultPerPage_ != 0) {
|
||||
output.writeInt32(3, resultPerPage_);
|
||||
}
|
||||
unknownFields.writeTo(output);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int getSerializedSize() {
|
||||
int size = memoizedSize;
|
||||
if (size != -1) return size;
|
||||
|
||||
size = 0;
|
||||
if (!getQueryBytes().isEmpty()) {
|
||||
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, query_);
|
||||
}
|
||||
if (pageNumber_ != 0) {
|
||||
size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, pageNumber_);
|
||||
}
|
||||
if (resultPerPage_ != 0) {
|
||||
size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, resultPerPage_);
|
||||
}
|
||||
size += unknownFields.getSerializedSize();
|
||||
memoizedSize = size;
|
||||
return size;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public boolean equals(final java.lang.Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3)) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 other =
|
||||
(akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3) obj;
|
||||
|
||||
if (!getQuery().equals(other.getQuery())) return false;
|
||||
if (getPageNumber() != other.getPageNumber()) return false;
|
||||
if (getResultPerPage() != other.getResultPerPage()) return false;
|
||||
if (!unknownFields.equals(other.unknownFields)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public int hashCode() {
|
||||
if (memoizedHashCode != 0) {
|
||||
return memoizedHashCode;
|
||||
}
|
||||
int hash = 41;
|
||||
hash = (19 * hash) + getDescriptor().hashCode();
|
||||
hash = (37 * hash) + QUERY_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getQuery().hashCode();
|
||||
hash = (37 * hash) + PAGE_NUMBER_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getPageNumber();
|
||||
hash = (37 * hash) + RESULT_PER_PAGE_FIELD_NUMBER;
|
||||
hash = (53 * hash) + getResultPerPage();
|
||||
hash = (29 * hash) + unknownFields.hashCode();
|
||||
memoizedHashCode = hash;
|
||||
return hash;
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseFrom(
|
||||
java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseFrom(
|
||||
java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseFrom(
|
||||
com.google.protobuf.ByteString data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseFrom(
|
||||
com.google.protobuf.ByteString data,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseFrom(byte[] data)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseFrom(
|
||||
byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return PARSER.parseFrom(data, extensionRegistry);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseFrom(
|
||||
java.io.InputStream input) throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseFrom(
|
||||
java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
|
||||
PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseDelimitedFrom(
|
||||
java.io.InputStream input) throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseDelimitedFrom(
|
||||
java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(
|
||||
PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseFrom(
|
||||
com.google.protobuf.CodedInputStream input) throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parseFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
|
||||
PARSER, input, extensionRegistry);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder newBuilderForType() {
|
||||
return newBuilder();
|
||||
}
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return DEFAULT_INSTANCE.toBuilder();
|
||||
}
|
||||
|
||||
public static Builder newBuilder(
|
||||
akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 prototype) {
|
||||
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder toBuilder() {
|
||||
return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected Builder newBuilderForType(
|
||||
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
Builder builder = new Builder(parent);
|
||||
return builder;
|
||||
}
|
||||
/** Protobuf type {@code MyMessageV3} */
|
||||
public static final class Builder
|
||||
extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
|
||||
implements
|
||||
// @@protoc_insertion_point(builder_implements:MyMessageV3)
|
||||
akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3OrBuilder {
|
||||
public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
|
||||
return akka.remote.protobuf.v3.ProtobufProtocolV3.internal_static_MyMessageV3_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internalGetFieldAccessorTable() {
|
||||
return akka.remote.protobuf.v3.ProtobufProtocolV3
|
||||
.internal_static_MyMessageV3_fieldAccessorTable.ensureFieldAccessorsInitialized(
|
||||
akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3.class,
|
||||
akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3.Builder.class);
|
||||
}
|
||||
|
||||
// Construct using akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3.newBuilder()
|
||||
private Builder() {
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
|
||||
super(parent);
|
||||
maybeForceBuilderInitialization();
|
||||
}
|
||||
|
||||
private void maybeForceBuilderInitialization() {
|
||||
if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) {}
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clear() {
|
||||
super.clear();
|
||||
query_ = "";
|
||||
|
||||
pageNumber_ = 0;
|
||||
|
||||
resultPerPage_ = 0;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
|
||||
return akka.remote.protobuf.v3.ProtobufProtocolV3.internal_static_MyMessageV3_descriptor;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 getDefaultInstanceForType() {
|
||||
return akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3.getDefaultInstance();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 build() {
|
||||
akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 result = buildPartial();
|
||||
if (!result.isInitialized()) {
|
||||
throw newUninitializedMessageException(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 buildPartial() {
|
||||
akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 result =
|
||||
new akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3(this);
|
||||
result.query_ = query_;
|
||||
result.pageNumber_ = pageNumber_;
|
||||
result.resultPerPage_ = resultPerPage_;
|
||||
onBuilt();
|
||||
return result;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clone() {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder setField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
|
||||
return super.setField(field, value);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
|
||||
return super.clearField(field);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
|
||||
return super.clearOneof(oneof);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder setRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field,
|
||||
int index,
|
||||
java.lang.Object value) {
|
||||
return super.setRepeatedField(field, index, value);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder addRepeatedField(
|
||||
com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
|
||||
return super.addRepeatedField(field, value);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(com.google.protobuf.Message other) {
|
||||
if (other instanceof akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3) {
|
||||
return mergeFrom((akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3) other);
|
||||
} else {
|
||||
super.mergeFrom(other);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public Builder mergeFrom(akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 other) {
|
||||
if (other == akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3.getDefaultInstance())
|
||||
return this;
|
||||
if (!other.getQuery().isEmpty()) {
|
||||
query_ = other.query_;
|
||||
onChanged();
|
||||
}
|
||||
if (other.getPageNumber() != 0) {
|
||||
setPageNumber(other.getPageNumber());
|
||||
}
|
||||
if (other.getResultPerPage() != 0) {
|
||||
setResultPerPage(other.getResultPerPage());
|
||||
}
|
||||
this.mergeUnknownFields(other.unknownFields);
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final boolean isInitialized() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public Builder mergeFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws java.io.IOException {
|
||||
akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 parsedMessage = null;
|
||||
try {
|
||||
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
|
||||
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
|
||||
parsedMessage =
|
||||
(akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3) e.getUnfinishedMessage();
|
||||
throw e.unwrapIOException();
|
||||
} finally {
|
||||
if (parsedMessage != null) {
|
||||
mergeFrom(parsedMessage);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private java.lang.Object query_ = "";
|
||||
/** <code>string query = 1;</code> */
|
||||
public java.lang.String getQuery() {
|
||||
java.lang.Object ref = query_;
|
||||
if (!(ref instanceof java.lang.String)) {
|
||||
com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
|
||||
java.lang.String s = bs.toStringUtf8();
|
||||
query_ = s;
|
||||
return s;
|
||||
} else {
|
||||
return (java.lang.String) ref;
|
||||
}
|
||||
}
|
||||
/** <code>string query = 1;</code> */
|
||||
public com.google.protobuf.ByteString getQueryBytes() {
|
||||
java.lang.Object ref = query_;
|
||||
if (ref instanceof String) {
|
||||
com.google.protobuf.ByteString b =
|
||||
com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
|
||||
query_ = b;
|
||||
return b;
|
||||
} else {
|
||||
return (com.google.protobuf.ByteString) ref;
|
||||
}
|
||||
}
|
||||
/** <code>string query = 1;</code> */
|
||||
public Builder setQuery(java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
query_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/** <code>string query = 1;</code> */
|
||||
public Builder clearQuery() {
|
||||
|
||||
query_ = getDefaultInstance().getQuery();
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/** <code>string query = 1;</code> */
|
||||
public Builder setQueryBytes(com.google.protobuf.ByteString value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
checkByteStringIsUtf8(value);
|
||||
|
||||
query_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
private int pageNumber_;
|
||||
/** <code>int32 page_number = 2;</code> */
|
||||
public int getPageNumber() {
|
||||
return pageNumber_;
|
||||
}
|
||||
/** <code>int32 page_number = 2;</code> */
|
||||
public Builder setPageNumber(int value) {
|
||||
|
||||
pageNumber_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/** <code>int32 page_number = 2;</code> */
|
||||
public Builder clearPageNumber() {
|
||||
|
||||
pageNumber_ = 0;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
private int resultPerPage_;
|
||||
/** <code>int32 result_per_page = 3;</code> */
|
||||
public int getResultPerPage() {
|
||||
return resultPerPage_;
|
||||
}
|
||||
/** <code>int32 result_per_page = 3;</code> */
|
||||
public Builder setResultPerPage(int value) {
|
||||
|
||||
resultPerPage_ = value;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
/** <code>int32 result_per_page = 3;</code> */
|
||||
public Builder clearResultPerPage() {
|
||||
|
||||
resultPerPage_ = 0;
|
||||
onChanged();
|
||||
return this;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final Builder setUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.setUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public final Builder mergeUnknownFields(
|
||||
final com.google.protobuf.UnknownFieldSet unknownFields) {
|
||||
return super.mergeUnknownFields(unknownFields);
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(builder_scope:MyMessageV3)
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(class_scope:MyMessageV3)
|
||||
private static final akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 DEFAULT_INSTANCE;
|
||||
|
||||
static {
|
||||
DEFAULT_INSTANCE = new akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3();
|
||||
}
|
||||
|
||||
public static akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 getDefaultInstance() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Parser<MyMessageV3> PARSER =
|
||||
new com.google.protobuf.AbstractParser<MyMessageV3>() {
|
||||
@java.lang.Override
|
||||
public MyMessageV3 parsePartialFrom(
|
||||
com.google.protobuf.CodedInputStream input,
|
||||
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
|
||||
throws com.google.protobuf.InvalidProtocolBufferException {
|
||||
return new MyMessageV3(input, extensionRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
public static com.google.protobuf.Parser<MyMessageV3> parser() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public com.google.protobuf.Parser<MyMessageV3> getParserForType() {
|
||||
return PARSER;
|
||||
}
|
||||
|
||||
@java.lang.Override
|
||||
public akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3 getDefaultInstanceForType() {
|
||||
return DEFAULT_INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
private static final com.google.protobuf.Descriptors.Descriptor
|
||||
internal_static_MyMessageV3_descriptor;
|
||||
private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
|
||||
internal_static_MyMessageV3_fieldAccessorTable;
|
||||
|
||||
public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
private static com.google.protobuf.Descriptors.FileDescriptor descriptor;
|
||||
|
||||
static {
|
||||
java.lang.String[] descriptorData = {
|
||||
"\n\030ProtobufProtocolV3.proto\"J\n\013MyMessageV"
|
||||
+ "3\022\r\n\005query\030\001 \001(\t\022\023\n\013page_number\030\002 \001(\005\022\027\n"
|
||||
+ "\017result_per_page\030\003 \001(\005B\031\n\027akka.remote.pr"
|
||||
+ "otobuf.v3b\006proto3"
|
||||
};
|
||||
descriptor =
|
||||
com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(
|
||||
descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {});
|
||||
internal_static_MyMessageV3_descriptor = getDescriptor().getMessageTypes().get(0);
|
||||
internal_static_MyMessageV3_fieldAccessorTable =
|
||||
new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
|
||||
internal_static_MyMessageV3_descriptor,
|
||||
new java.lang.String[] {
|
||||
"Query", "PageNumber", "ResultPerPage",
|
||||
});
|
||||
}
|
||||
|
||||
// @@protoc_insertion_point(outer_class_scope)
|
||||
}
|
||||
16
akka-remote/src/test/protobuf/ProtobufProtocolV3.proto
Normal file
16
akka-remote/src/test/protobuf/ProtobufProtocolV3.proto
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (C) 2019 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
// Generated with protoc 3 compiler and copied do test src
|
||||
// doesen't use protobufGenerate yet as that replaces google packages
|
||||
// with akka
|
||||
syntax = "proto3";
|
||||
|
||||
option java_package = "akka.remote.protobuf.v3";
|
||||
|
||||
message MyMessageV3 {
|
||||
string query = 1;
|
||||
int32 page_number = 2;
|
||||
int32 result_per_page = 3;
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ import akka.remote.WireFormats.SerializedMessage
|
|||
import akka.remote.ProtobufProtocol.MyMessage
|
||||
import akka.remote.MessageSerializer
|
||||
import akka.actor.ExtendedActorSystem
|
||||
import akka.remote.protobuf.v3.ProtobufProtocolV3.MyMessageV3
|
||||
|
||||
class ProtobufSerializerSpec extends AkkaSpec {
|
||||
|
||||
|
|
@ -20,11 +21,13 @@ class ProtobufSerializerSpec extends AkkaSpec {
|
|||
"resolve protobuf serializer" in {
|
||||
ser.serializerFor(classOf[SerializedMessage]).getClass should ===(classOf[ProtobufSerializer])
|
||||
ser.serializerFor(classOf[MyMessage]).getClass should ===(classOf[ProtobufSerializer])
|
||||
ser.serializerFor(classOf[MyMessageV3]).getClass should ===(classOf[ProtobufSerializer])
|
||||
}
|
||||
|
||||
"work for SerializedMessage (just an akka.protobuf message)" in {
|
||||
// create a protobuf message
|
||||
val protobufMessage = MessageSerializer.serialize(system.asInstanceOf[ExtendedActorSystem], "hello")
|
||||
val protobufMessage: SerializedMessage =
|
||||
MessageSerializer.serialize(system.asInstanceOf[ExtendedActorSystem], "hello")
|
||||
// serialize it with ProtobufSerializer
|
||||
val bytes = ser.serialize(protobufMessage).get
|
||||
// deserialize the bytes with ProtobufSerializer
|
||||
|
|
@ -33,5 +36,13 @@ class ProtobufSerializerSpec extends AkkaSpec {
|
|||
deserialized.getMessage should ===(protobufMessage.getMessage) // same "hello"
|
||||
}
|
||||
|
||||
"work for a serialized protobuf v3 message" in {
|
||||
val protobufV3Message: MyMessageV3 =
|
||||
MyMessageV3.newBuilder().setQuery("query1").setPageNumber(1).setResultPerPage(2).build()
|
||||
val bytes = ser.serialize(protobufV3Message).get
|
||||
val deserialized: MyMessageV3 = ser.deserialize(bytes, protobufV3Message.getClass).get
|
||||
protobufV3Message should ===(deserialized)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,6 +134,8 @@ object Dependencies {
|
|||
|
||||
// reactive streams tck
|
||||
val reactiveStreamsTck = "org.reactivestreams" % "reactive-streams-tck" % "1.0.2" % "test" // CC0
|
||||
|
||||
val protobufRuntime = "com.google.protobuf" % "protobuf-java" % "3.9.0" % "test"
|
||||
}
|
||||
|
||||
object Provided {
|
||||
|
|
@ -184,7 +186,7 @@ object Dependencies {
|
|||
val remoteDependencies = Seq(netty, aeronDriver, aeronClient)
|
||||
val remoteOptionalDependencies = remoteDependencies.map(_ % "optional")
|
||||
|
||||
val remote = l ++= Seq(agrona, Test.junit, Test.scalatest.value, Test.jimfs) ++ remoteOptionalDependencies
|
||||
val remote = l ++= Seq(agrona, Test.junit, Test.scalatest.value, Test.jimfs, Test.protobufRuntime) ++ remoteOptionalDependencies
|
||||
|
||||
val remoteTests = l ++= Seq(Test.junit, Test.scalatest.value, Test.scalaXml) ++ remoteDependencies
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue