diff --git a/Makefile b/Makefile index e12e60c2..a6372c89 100644 --- a/Makefile +++ b/Makefile @@ -34,3 +34,8 @@ test-cluster: setup-cluster coverage: setup lein code-coverage docker-compose down + +proto: + protoc -I=resources --java_out=test/ resources/proto/example.proto + protoc -I=resources --java_out=test/ resources/proto/person.proto + protoc -I=resources --java_out=src/ resources/proto/message-payload.proto \ No newline at end of file diff --git a/project.clj b/project.clj index 8897dad6..3899bae3 100644 --- a/project.clj +++ b/project.clj @@ -35,8 +35,7 @@ [org.clojure/clojure "1.10.3"] [org.clojure/tools.logging "1.1.0"] [nrepl/nrepl "0.8.3"] - [clojusc/protobuf "3.5.1-v1.1"] - [org.flatland/protobuf "0.8.1"] + [clojusc/protobuf "3.5.1-v1.1"] ;Compile all the proto with only protoc version 3.5.1 since clojusc supports only till 3.5.1 [prismatic/schema "1.1.12"] [clj-statsd "0.4.0"] [ring/ring "1.9.3"] @@ -62,14 +61,13 @@ :pedantic? :warn :java-source-paths ["src/com"] :aliases {"code-coverage" ["with-profile" "test" "cloverage" "--output" "coverage" "--lcov"]} - :aot [ziggurat.kafka-consumer.invalid-return-type-exception ziggurat.init ziggurat.config ziggurat.producer ziggurat.sentry ziggurat.metrics ziggurat.fixtures] + :aot [ziggurat.kafka-consumer.invalid-return-type-exception] :profiles {:uberjar {:aot :all :global-vars {*warn-on-reflection* true} :pedantic? :abort} :test {:java-source-paths ["src/com" "test/com"] :jvm-opts ["-Dlog4j.configurationFile=resources/log4j2.test.xml"] - :dependencies [[com.google.protobuf/protobuf-java "3.17.0"] - [junit/junit "4.13.2"] + :dependencies [[junit/junit "4.13.2"] [org.hamcrest/hamcrest-core "2.2"] [org.apache.kafka/kafka-streams "2.8.0" :classifier "test" :exclusions [org.slf4j/slf4j-log4j12 log4j]] [org.apache.kafka/kafka-clients "2.8.0" :classifier "test"] diff --git a/resources/config.test.edn b/resources/config.test.edn index 1b476b22..d9149279 100644 --- a/resources/config.test.edn +++ b/resources/config.test.edn @@ -11,7 +11,7 @@ :worker-count [10 :int] :queue-size [10 :int] :thread-termination-wait-s [1 :int]} - :rabbit-mq-connection {:host "127.0.0.1" + :rabbit-mq-connection {:host "localhost" :port [5672 :int] :username "guest" :password "guest" diff --git a/resources/proto/example.proto b/resources/proto/example.proto new file mode 100644 index 00000000..9bd9d3ae --- /dev/null +++ b/resources/proto/example.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package com.gojek.test.proto; + +option java_package = "com.gojek.test.proto"; +option java_outer_classname = "Example"; + +message Photo { + int32 id = 1; + string path = 2; + bytes image = 6; + + message Label { + string item = 1; + bool exists = 2; + } + + message Attr { + string key = 1; + string val = 2; + } + + message Tag { + int32 person_id = 1; + int32 y_coord = 3; + int32 width = 4; + int32 height = 5; + } +} \ No newline at end of file diff --git a/resources/proto/message-payload.proto b/resources/proto/message-payload.proto new file mode 100644 index 00000000..2926ffb1 --- /dev/null +++ b/resources/proto/message-payload.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +// use protoc v3.17.3 to compile the proto +package com.ziggurat.proto; + +option java_package = "com.ziggurat.proto"; +option java_outer_classname = "MessagePayloadProto"; + +message MessagePayload { + message Metadata{ + string topic = 1; + int64 timestamp = 2; + int32 partition = 3; + } + bytes message = 1; + string topic_entity = 2; + int32 retry_count = 3; + Metadata metadata = 4; +} diff --git a/test/com/gojek/test/proto/person.proto b/resources/proto/person.proto similarity index 100% rename from test/com/gojek/test/proto/person.proto rename to resources/proto/person.proto diff --git a/src/com/ziggurat/proto/MessagePayloadProto.java b/src/com/ziggurat/proto/MessagePayloadProto.java new file mode 100644 index 00000000..309b6c21 --- /dev/null +++ b/src/com/ziggurat/proto/MessagePayloadProto.java @@ -0,0 +1,1572 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: proto/message-payload.proto + +package com.ziggurat.proto; + +public final class MessagePayloadProto { + private MessagePayloadProto() {} + 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 MessagePayloadOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.ziggurat.proto.MessagePayload) + com.google.protobuf.MessageOrBuilder { + + /** + * bytes message = 1; + */ + com.google.protobuf.ByteString getMessage(); + + /** + * string topic_entity = 2; + */ + java.lang.String getTopicEntity(); + /** + * string topic_entity = 2; + */ + com.google.protobuf.ByteString + getTopicEntityBytes(); + + /** + * int32 retry_count = 3; + */ + int getRetryCount(); + + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + boolean hasMetadata(); + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata getMetadata(); + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + com.ziggurat.proto.MessagePayloadProto.MessagePayload.MetadataOrBuilder getMetadataOrBuilder(); + } + /** + * Protobuf type {@code com.ziggurat.proto.MessagePayload} + */ + public static final class MessagePayload extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.ziggurat.proto.MessagePayload) + MessagePayloadOrBuilder { + private static final long serialVersionUID = 0L; + // Use MessagePayload.newBuilder() to construct. + private MessagePayload(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private MessagePayload() { + message_ = com.google.protobuf.ByteString.EMPTY; + topicEntity_ = ""; + retryCount_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private MessagePayload( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + 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; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + + message_ = input.readBytes(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + topicEntity_ = s; + break; + } + case 24: { + + retryCount_ = input.readInt32(); + break; + } + case 34: { + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.Builder subBuilder = null; + if (metadata_ != null) { + subBuilder = metadata_.toBuilder(); + } + metadata_ = input.readMessage(com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(metadata_); + metadata_ = subBuilder.buildPartial(); + } + + 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 com.ziggurat.proto.MessagePayloadProto.internal_static_com_ziggurat_proto_MessagePayload_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.ziggurat.proto.MessagePayloadProto.internal_static_com_ziggurat_proto_MessagePayload_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.ziggurat.proto.MessagePayloadProto.MessagePayload.class, com.ziggurat.proto.MessagePayloadProto.MessagePayload.Builder.class); + } + + public interface MetadataOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.ziggurat.proto.MessagePayload.Metadata) + com.google.protobuf.MessageOrBuilder { + + /** + * string topic = 1; + */ + java.lang.String getTopic(); + /** + * string topic = 1; + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * int64 timestamp = 2; + */ + long getTimestamp(); + + /** + * int32 partition = 3; + */ + int getPartition(); + } + /** + * Protobuf type {@code com.ziggurat.proto.MessagePayload.Metadata} + */ + public static final class Metadata extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.ziggurat.proto.MessagePayload.Metadata) + MetadataOrBuilder { + private static final long serialVersionUID = 0L; + // Use Metadata.newBuilder() to construct. + private Metadata(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Metadata() { + topic_ = ""; + timestamp_ = 0L; + partition_ = 0; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Metadata( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + 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; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + topic_ = s; + break; + } + case 16: { + + timestamp_ = input.readInt64(); + break; + } + case 24: { + + partition_ = input.readInt32(); + 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 com.ziggurat.proto.MessagePayloadProto.internal_static_com_ziggurat_proto_MessagePayload_Metadata_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.ziggurat.proto.MessagePayloadProto.internal_static_com_ziggurat_proto_MessagePayload_Metadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.class, com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.Builder.class); + } + + public static final int TOPIC_FIELD_NUMBER = 1; + private volatile java.lang.Object topic_; + /** + * string topic = 1; + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + 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(); + topic_ = s; + return s; + } + } + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TIMESTAMP_FIELD_NUMBER = 2; + private long timestamp_; + /** + * int64 timestamp = 2; + */ + public long getTimestamp() { + return timestamp_; + } + + public static final int PARTITION_FIELD_NUMBER = 3; + private int partition_; + /** + * int32 partition = 3; + */ + public int getPartition() { + return partition_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getTopicBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, topic_); + } + if (timestamp_ != 0L) { + output.writeInt64(2, timestamp_); + } + if (partition_ != 0) { + output.writeInt32(3, partition_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getTopicBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, topic_); + } + if (timestamp_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(2, timestamp_); + } + if (partition_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, partition_); + } + 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 com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata)) { + return super.equals(obj); + } + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata other = (com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata) obj; + + boolean result = true; + result = result && getTopic() + .equals(other.getTopic()); + result = result && (getTimestamp() + == other.getTimestamp()); + result = result && (getPartition() + == other.getPartition()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTimestamp()); + hash = (37 * hash) + PARTITION_FIELD_NUMBER; + hash = (53 * hash) + getPartition(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata 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 com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata 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 com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + 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 com.ziggurat.proto.MessagePayload.Metadata} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.ziggurat.proto.MessagePayload.Metadata) + com.ziggurat.proto.MessagePayloadProto.MessagePayload.MetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.ziggurat.proto.MessagePayloadProto.internal_static_com_ziggurat_proto_MessagePayload_Metadata_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.ziggurat.proto.MessagePayloadProto.internal_static_com_ziggurat_proto_MessagePayload_Metadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.class, com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.Builder.class); + } + + // Construct using com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + topic_ = ""; + + timestamp_ = 0L; + + partition_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.ziggurat.proto.MessagePayloadProto.internal_static_com_ziggurat_proto_MessagePayload_Metadata_descriptor; + } + + public com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata getDefaultInstanceForType() { + return com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.getDefaultInstance(); + } + + public com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata build() { + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata buildPartial() { + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata result = new com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata(this); + result.topic_ = topic_; + result.timestamp_ = timestamp_; + result.partition_ = partition_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata) { + return mergeFrom((com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata other) { + if (other == com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.getDefaultInstance()) return this; + if (!other.getTopic().isEmpty()) { + topic_ = other.topic_; + onChanged(); + } + if (other.getTimestamp() != 0L) { + setTimestamp(other.getTimestamp()); + } + if (other.getPartition() != 0) { + setPartition(other.getPartition()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object topic_ = ""; + /** + * string topic = 1; + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topic_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string topic = 1; + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string topic = 1; + */ + public Builder setTopic( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + topic_ = value; + onChanged(); + return this; + } + /** + * string topic = 1; + */ + public Builder clearTopic() { + + topic_ = getDefaultInstance().getTopic(); + onChanged(); + return this; + } + /** + * string topic = 1; + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topic_ = value; + onChanged(); + return this; + } + + private long timestamp_ ; + /** + * int64 timestamp = 2; + */ + public long getTimestamp() { + return timestamp_; + } + /** + * int64 timestamp = 2; + */ + public Builder setTimestamp(long value) { + + timestamp_ = value; + onChanged(); + return this; + } + /** + * int64 timestamp = 2; + */ + public Builder clearTimestamp() { + + timestamp_ = 0L; + onChanged(); + return this; + } + + private int partition_ ; + /** + * int32 partition = 3; + */ + public int getPartition() { + return partition_; + } + /** + * int32 partition = 3; + */ + public Builder setPartition(int value) { + + partition_ = value; + onChanged(); + return this; + } + /** + * int32 partition = 3; + */ + public Builder clearPartition() { + + partition_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.ziggurat.proto.MessagePayload.Metadata) + } + + // @@protoc_insertion_point(class_scope:com.ziggurat.proto.MessagePayload.Metadata) + private static final com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata(); + } + + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Metadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Metadata(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public static final int MESSAGE_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString message_; + /** + * bytes message = 1; + */ + public com.google.protobuf.ByteString getMessage() { + return message_; + } + + public static final int TOPIC_ENTITY_FIELD_NUMBER = 2; + private volatile java.lang.Object topicEntity_; + /** + * string topic_entity = 2; + */ + public java.lang.String getTopicEntity() { + java.lang.Object ref = topicEntity_; + 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(); + topicEntity_ = s; + return s; + } + } + /** + * string topic_entity = 2; + */ + public com.google.protobuf.ByteString + getTopicEntityBytes() { + java.lang.Object ref = topicEntity_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topicEntity_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RETRY_COUNT_FIELD_NUMBER = 3; + private int retryCount_; + /** + * int32 retry_count = 3; + */ + public int getRetryCount() { + return retryCount_; + } + + public static final int METADATA_FIELD_NUMBER = 4; + private com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata metadata_; + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public boolean hasMetadata() { + return metadata_ != null; + } + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata getMetadata() { + return metadata_ == null ? com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.getDefaultInstance() : metadata_; + } + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public com.ziggurat.proto.MessagePayloadProto.MessagePayload.MetadataOrBuilder getMetadataOrBuilder() { + return getMetadata(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!message_.isEmpty()) { + output.writeBytes(1, message_); + } + if (!getTopicEntityBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, topicEntity_); + } + if (retryCount_ != 0) { + output.writeInt32(3, retryCount_); + } + if (metadata_ != null) { + output.writeMessage(4, getMetadata()); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!message_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(1, message_); + } + if (!getTopicEntityBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, topicEntity_); + } + if (retryCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, retryCount_); + } + if (metadata_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(4, getMetadata()); + } + 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 com.ziggurat.proto.MessagePayloadProto.MessagePayload)) { + return super.equals(obj); + } + com.ziggurat.proto.MessagePayloadProto.MessagePayload other = (com.ziggurat.proto.MessagePayloadProto.MessagePayload) obj; + + boolean result = true; + result = result && getMessage() + .equals(other.getMessage()); + result = result && getTopicEntity() + .equals(other.getTopicEntity()); + result = result && (getRetryCount() + == other.getRetryCount()); + result = result && (hasMetadata() == other.hasMetadata()); + if (hasMetadata()) { + result = result && getMetadata() + .equals(other.getMetadata()); + } + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + hash = (37 * hash) + TOPIC_ENTITY_FIELD_NUMBER; + hash = (53 * hash) + getTopicEntity().hashCode(); + hash = (37 * hash) + RETRY_COUNT_FIELD_NUMBER; + hash = (53 * hash) + getRetryCount(); + if (hasMetadata()) { + hash = (37 * hash) + METADATA_FIELD_NUMBER; + hash = (53 * hash) + getMetadata().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload 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 com.ziggurat.proto.MessagePayloadProto.MessagePayload parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload 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 com.ziggurat.proto.MessagePayloadProto.MessagePayload parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.ziggurat.proto.MessagePayloadProto.MessagePayload prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + 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 com.ziggurat.proto.MessagePayload} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.ziggurat.proto.MessagePayload) + com.ziggurat.proto.MessagePayloadProto.MessagePayloadOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.ziggurat.proto.MessagePayloadProto.internal_static_com_ziggurat_proto_MessagePayload_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.ziggurat.proto.MessagePayloadProto.internal_static_com_ziggurat_proto_MessagePayload_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.ziggurat.proto.MessagePayloadProto.MessagePayload.class, com.ziggurat.proto.MessagePayloadProto.MessagePayload.Builder.class); + } + + // Construct using com.ziggurat.proto.MessagePayloadProto.MessagePayload.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + message_ = com.google.protobuf.ByteString.EMPTY; + + topicEntity_ = ""; + + retryCount_ = 0; + + if (metadataBuilder_ == null) { + metadata_ = null; + } else { + metadata_ = null; + metadataBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.ziggurat.proto.MessagePayloadProto.internal_static_com_ziggurat_proto_MessagePayload_descriptor; + } + + public com.ziggurat.proto.MessagePayloadProto.MessagePayload getDefaultInstanceForType() { + return com.ziggurat.proto.MessagePayloadProto.MessagePayload.getDefaultInstance(); + } + + public com.ziggurat.proto.MessagePayloadProto.MessagePayload build() { + com.ziggurat.proto.MessagePayloadProto.MessagePayload result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.ziggurat.proto.MessagePayloadProto.MessagePayload buildPartial() { + com.ziggurat.proto.MessagePayloadProto.MessagePayload result = new com.ziggurat.proto.MessagePayloadProto.MessagePayload(this); + result.message_ = message_; + result.topicEntity_ = topicEntity_; + result.retryCount_ = retryCount_; + if (metadataBuilder_ == null) { + result.metadata_ = metadata_; + } else { + result.metadata_ = metadataBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.ziggurat.proto.MessagePayloadProto.MessagePayload) { + return mergeFrom((com.ziggurat.proto.MessagePayloadProto.MessagePayload)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.ziggurat.proto.MessagePayloadProto.MessagePayload other) { + if (other == com.ziggurat.proto.MessagePayloadProto.MessagePayload.getDefaultInstance()) return this; + if (other.getMessage() != com.google.protobuf.ByteString.EMPTY) { + setMessage(other.getMessage()); + } + if (!other.getTopicEntity().isEmpty()) { + topicEntity_ = other.topicEntity_; + onChanged(); + } + if (other.getRetryCount() != 0) { + setRetryCount(other.getRetryCount()); + } + if (other.hasMetadata()) { + mergeMetadata(other.getMetadata()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.ziggurat.proto.MessagePayloadProto.MessagePayload parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.ziggurat.proto.MessagePayloadProto.MessagePayload) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private com.google.protobuf.ByteString message_ = com.google.protobuf.ByteString.EMPTY; + /** + * bytes message = 1; + */ + public com.google.protobuf.ByteString getMessage() { + return message_; + } + /** + * bytes message = 1; + */ + public Builder setMessage(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + * bytes message = 1; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + + private java.lang.Object topicEntity_ = ""; + /** + * string topic_entity = 2; + */ + public java.lang.String getTopicEntity() { + java.lang.Object ref = topicEntity_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + topicEntity_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string topic_entity = 2; + */ + public com.google.protobuf.ByteString + getTopicEntityBytes() { + java.lang.Object ref = topicEntity_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topicEntity_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string topic_entity = 2; + */ + public Builder setTopicEntity( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + topicEntity_ = value; + onChanged(); + return this; + } + /** + * string topic_entity = 2; + */ + public Builder clearTopicEntity() { + + topicEntity_ = getDefaultInstance().getTopicEntity(); + onChanged(); + return this; + } + /** + * string topic_entity = 2; + */ + public Builder setTopicEntityBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + topicEntity_ = value; + onChanged(); + return this; + } + + private int retryCount_ ; + /** + * int32 retry_count = 3; + */ + public int getRetryCount() { + return retryCount_; + } + /** + * int32 retry_count = 3; + */ + public Builder setRetryCount(int value) { + + retryCount_ = value; + onChanged(); + return this; + } + /** + * int32 retry_count = 3; + */ + public Builder clearRetryCount() { + + retryCount_ = 0; + onChanged(); + return this; + } + + private com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata metadata_ = null; + private com.google.protobuf.SingleFieldBuilderV3< + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata, com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.Builder, com.ziggurat.proto.MessagePayloadProto.MessagePayload.MetadataOrBuilder> metadataBuilder_; + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public boolean hasMetadata() { + return metadataBuilder_ != null || metadata_ != null; + } + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata getMetadata() { + if (metadataBuilder_ == null) { + return metadata_ == null ? com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.getDefaultInstance() : metadata_; + } else { + return metadataBuilder_.getMessage(); + } + } + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public Builder setMetadata(com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata value) { + if (metadataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + metadata_ = value; + onChanged(); + } else { + metadataBuilder_.setMessage(value); + } + + return this; + } + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public Builder setMetadata( + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.Builder builderForValue) { + if (metadataBuilder_ == null) { + metadata_ = builderForValue.build(); + onChanged(); + } else { + metadataBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public Builder mergeMetadata(com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata value) { + if (metadataBuilder_ == null) { + if (metadata_ != null) { + metadata_ = + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.newBuilder(metadata_).mergeFrom(value).buildPartial(); + } else { + metadata_ = value; + } + onChanged(); + } else { + metadataBuilder_.mergeFrom(value); + } + + return this; + } + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public Builder clearMetadata() { + if (metadataBuilder_ == null) { + metadata_ = null; + onChanged(); + } else { + metadata_ = null; + metadataBuilder_ = null; + } + + return this; + } + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.Builder getMetadataBuilder() { + + onChanged(); + return getMetadataFieldBuilder().getBuilder(); + } + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + public com.ziggurat.proto.MessagePayloadProto.MessagePayload.MetadataOrBuilder getMetadataOrBuilder() { + if (metadataBuilder_ != null) { + return metadataBuilder_.getMessageOrBuilder(); + } else { + return metadata_ == null ? + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.getDefaultInstance() : metadata_; + } + } + /** + * .com.ziggurat.proto.MessagePayload.Metadata metadata = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata, com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.Builder, com.ziggurat.proto.MessagePayloadProto.MessagePayload.MetadataOrBuilder> + getMetadataFieldBuilder() { + if (metadataBuilder_ == null) { + metadataBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< + com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata, com.ziggurat.proto.MessagePayloadProto.MessagePayload.Metadata.Builder, com.ziggurat.proto.MessagePayloadProto.MessagePayload.MetadataOrBuilder>( + getMetadata(), + getParentForChildren(), + isClean()); + metadata_ = null; + } + return metadataBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.ziggurat.proto.MessagePayload) + } + + // @@protoc_insertion_point(class_scope:com.ziggurat.proto.MessagePayload) + private static final com.ziggurat.proto.MessagePayloadProto.MessagePayload DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.ziggurat.proto.MessagePayloadProto.MessagePayload(); + } + + public static com.ziggurat.proto.MessagePayloadProto.MessagePayload getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public MessagePayload parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new MessagePayload(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.ziggurat.proto.MessagePayloadProto.MessagePayload getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_ziggurat_proto_MessagePayload_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_ziggurat_proto_MessagePayload_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_ziggurat_proto_MessagePayload_Metadata_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_ziggurat_proto_MessagePayload_Metadata_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\033proto/message-payload.proto\022\022com.ziggu" + + "rat.proto\"\314\001\n\016MessagePayload\022\017\n\007message\030" + + "\001 \001(\014\022\024\n\014topic_entity\030\002 \001(\t\022\023\n\013retry_cou" + + "nt\030\003 \001(\005\022=\n\010metadata\030\004 \001(\0132+.com.ziggura" + + "t.proto.MessagePayload.Metadata\032?\n\010Metad" + + "ata\022\r\n\005topic\030\001 \001(\t\022\021\n\ttimestamp\030\002 \001(\003\022\021\n" + + "\tpartition\030\003 \001(\005B)\n\022com.ziggurat.protoB\023" + + "MessagePayloadProtob\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_com_ziggurat_proto_MessagePayload_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_com_ziggurat_proto_MessagePayload_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_ziggurat_proto_MessagePayload_descriptor, + new java.lang.String[] { "Message", "TopicEntity", "RetryCount", "Metadata", }); + internal_static_com_ziggurat_proto_MessagePayload_Metadata_descriptor = + internal_static_com_ziggurat_proto_MessagePayload_descriptor.getNestedTypes().get(0); + internal_static_com_ziggurat_proto_MessagePayload_Metadata_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_ziggurat_proto_MessagePayload_Metadata_descriptor, + new java.lang.String[] { "Topic", "Timestamp", "Partition", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/src/ziggurat/config.clj b/src/ziggurat/config.clj index 3f479304..c85a56ca 100644 --- a/src/ziggurat/config.clj +++ b/src/ziggurat/config.clj @@ -94,6 +94,15 @@ (defn channel-retry-config [topic-entity channel] (get-in (ziggurat-config) [:stream-router topic-entity :channels channel :retry])) +(defn channel-retry-count [topic-entity channel] + (:count (channel-retry-config topic-entity channel))) + +(defn retry-count + [] + (if (get-in (ziggurat-config) [:retry :enabled] false) + (get-in (ziggurat-config) [:retry :count] -1) + -1)) + (defn- java-response "When returning config from -get or -getIn, we can either return a Map or string (based on the key/keys passed). Since we do not want to pass a ClojureMap to a Java application, we check whether the config-vals (config to be returned) diff --git a/src/ziggurat/init.clj b/src/ziggurat/init.clj index f49a5c3b..85aaa69c 100644 --- a/src/ziggurat/init.clj +++ b/src/ziggurat/init.clj @@ -7,6 +7,7 @@ [ziggurat.config :refer [ziggurat-config] :as config] [ziggurat.messaging.connection :as messaging-connection :refer [connection]] [ziggurat.messaging.consumer :as messaging-consumer] + [clojure.string :as str] [ziggurat.messaging.producer :as messaging-producer] [ziggurat.metrics :as metrics] [ziggurat.nrepl-server :as nrepl-server] @@ -179,6 +180,7 @@ {s/Keyword {:handler-fn (s/pred #(fn? %)) s/Keyword (s/pred #(fn? %))}})) +(declare BatchRoute) (s/defschema BatchRoute (s/conditional #(and (seq %) @@ -199,7 +201,7 @@ (throw (IllegalArgumentException. (format "Error! Route %s isn't present in the %s config" topic-entity route-type))) (when-not (set/subset? channels config-channels) (let [diff (set/difference channels config-channels)] - (throw (IllegalArgumentException. (format "Error! The channel(s) %s aren't present in the channels config of %s " (clojure.string/join "," diff) route-type)))))))))) + (throw (IllegalArgumentException. (format "Error! The channel(s) %s aren't present in the channels config of %s " (str/join "," diff) route-type)))))))))) (defn validate-routes [stream-routes batch-routes modes] (when (contains? (set modes) :stream-worker) diff --git a/src/ziggurat/kafka_consumer/consumer_handler.clj b/src/ziggurat/kafka_consumer/consumer_handler.clj index 35c45ed1..50a91946 100644 --- a/src/ziggurat/kafka_consumer/consumer_handler.clj +++ b/src/ziggurat/kafka_consumer/consumer_handler.clj @@ -2,7 +2,7 @@ (:require [clojure.tools.logging :as log] [ziggurat.config :refer :all] [ziggurat.messaging.producer :as producer] - [ziggurat.message-payload :refer [map->MessagePayload]] + [ziggurat.message-payload :refer [mk-message-payload]] [ziggurat.metrics :as metrics]) (:import (org.apache.kafka.common.errors WakeupException) (java.time Duration Instant) @@ -26,9 +26,7 @@ (producer/retry batch-payload)) ([batch current-retry-count topic-entity] (when (pos? (count batch)) - (let [message (map->MessagePayload {:message batch - :retry-count current-retry-count - :topic-entity topic-entity})] + (let [message (mk-message-payload batch topic-entity current-retry-count)] (producer/retry message))))) (defn validate-return-type @@ -50,9 +48,9 @@ (try (when (not-empty batch) (log/infof "[Consumer Group: %s] Processing the batch with %d messages" topic-entity batch-size) - (let [start-time (Instant/now) - result (batch-handler batch) - time-taken-in-millis (.toMillis (Duration/between start-time (Instant/now)))] + (let [start-time (Instant/now) + result (batch-handler batch) + time-taken-in-millis (.toMillis (Duration/between start-time (Instant/now)))] (validate-batch-processing-result result) (let [messages-to-be-retried (:retry result) to-be-retried-count (count messages-to-be-retried) @@ -74,7 +72,7 @@ [records topic-entity] (let [key-value-pairs (map (fn [^ConsumerRecord m] {:value (.value m) :key (.key m)}) records)] - (map->MessagePayload {:message key-value-pairs :topic-entity topic-entity}))) + (mk-message-payload key-value-pairs topic-entity))) (defn poll-for-messages [^Consumer consumer handler-fn topic-entity consumer-config] diff --git a/src/ziggurat/mapper.clj b/src/ziggurat/mapper.clj index e720198f..a41c3012 100644 --- a/src/ziggurat/mapper.clj +++ b/src/ziggurat/mapper.clj @@ -1,7 +1,7 @@ (ns ziggurat.mapper (:require [clojure.string :as str] [sentry-clj.async :as sentry] - [ziggurat.config :refer [ziggurat-config]] + [ziggurat.config :refer [ziggurat-config channel-retry-count]] [ziggurat.messaging.producer :as producer] [ziggurat.metrics :as metrics] [ziggurat.new-relic :as nr] @@ -12,7 +12,8 @@ (defn- send-msg-to-channel [channels message-payload return-code] (when-not (contains? (set channels) return-code) (throw (ex-info "Invalid mapper return code" {:code return-code}))) - (producer/publish-to-channel-instant-queue return-code message-payload)) + (let [message-payload (assoc message-payload :retry-count (channel-retry-count (:topic-entity message-payload) return-code))] + (producer/publish-to-channel-instant-queue return-code message-payload))) (defn- create-user-payload [message-payload] diff --git a/src/ziggurat/message_payload.clj b/src/ziggurat/message_payload.clj index 6e56770a..b5035e5f 100644 --- a/src/ziggurat/message_payload.clj +++ b/src/ziggurat/message_payload.clj @@ -1,4 +1,14 @@ (ns ziggurat.message-payload - (:require [schema.core :as s])) + (:require [schema.core :as s] + [ziggurat.config :refer [retry-count]])) (defrecord MessagePayload [message topic-entity]) + +(defn mk-message-payload + ([msg topic-entity] + (mk-message-payload msg topic-entity (retry-count))) + ([msg topic-entity retry-count] + {:message msg :topic-entity (name topic-entity) :retry-count retry-count})) + + + diff --git a/src/ziggurat/messaging/connection.clj b/src/ziggurat/messaging/connection.clj index 889601ea..f74d8e0e 100644 --- a/src/ziggurat/messaging/connection.clj +++ b/src/ziggurat/messaging/connection.clj @@ -15,6 +15,8 @@ [io.opentracing.contrib.rabbitmq TracingConnectionFactory] [com.rabbitmq.client.impl DefaultCredentialsProvider])) +(declare connection) + (defn is-connection-required? [] (let [stream-routes (:stream-routes (mount/args)) all-channels (reduce (fn [all-channel-vec [topic-entity _]] diff --git a/src/ziggurat/messaging/consumer.clj b/src/ziggurat/messaging/consumer.clj index 47c92677..a360e435 100644 --- a/src/ziggurat/messaging/consumer.clj +++ b/src/ziggurat/messaging/consumer.clj @@ -9,8 +9,22 @@ [ziggurat.mapper :as mpr] [ziggurat.messaging.connection :refer [connection]] [ziggurat.messaging.util :as util] + [ziggurat.middleware.default :as mw] + [ziggurat.sentry :refer [sentry-reporter]] + [ziggurat.messaging.util :refer :all] [ziggurat.metrics :as metrics] - [ziggurat.util.error :refer [report-error]])) + [ziggurat.util.error :refer [report-error]]) + (:import (com.ziggurat.proto MessagePayloadProto$MessagePayload) + (com.google.protobuf ByteString))) + +(defn- try-deserialize-message + [topic-entity-name message] + (let [from-proto (mw/deserialize-message message MessagePayloadProto$MessagePayload topic-entity-name)] + (if (nil? from-proto) + (into {} (nippy/thaw message)) ;Converting defrecord into map, since proto does not understand defrecord + (-> from-proto + (update :message #(.toByteArray ^ByteString %)) + (update :topic-entity keyword))))) (defn- reject-message [ch delivery-tag] @@ -27,11 +41,11 @@ (reject-message ch delivery-tag))))) (defn convert-and-ack-message - "De-serializes the message payload (`payload`) using `nippy/thaw` and converts it to `MessagePayload`. Acks the message - if `ack?` is true." + "De-serializes the message payload (`payload`) using `nippy/thaw` or `proto` (whichever of the two succeeds). + Acks the message if `ack?` is true." [ch {:keys [delivery-tag]} ^bytes payload ack? topic-entity] (try - (let [message (nippy/thaw payload)] + (let [message (try-deserialize-message topic-entity payload)] (when ack? (lb/ack ch delivery-tag)) message) diff --git a/src/ziggurat/messaging/producer.clj b/src/ziggurat/messaging/producer.clj index 8f561776..c7d66a41 100644 --- a/src/ziggurat/messaging/producer.clj +++ b/src/ziggurat/messaging/producer.clj @@ -8,6 +8,9 @@ [taoensso.nippy :as nippy] [ziggurat.config :refer [config ziggurat-config rabbitmq-config channel-retry-config]] [ziggurat.messaging.connection :refer [connection is-connection-required?]] + [ziggurat.messaging.util :refer :all] + [ziggurat.middleware.default :as mwd] + [ziggurat.sentry :refer [sentry-reporter]] [ziggurat.messaging.util :as util] [ziggurat.metrics :as metrics]) (:import (com.rabbitmq.client AlreadyClosedException) @@ -53,8 +56,8 @@ (let [host-endpoint (str "http://" (first hosts) ":" (get rmq-config :admin-port 15672)) resp (set-ha-policy-on-host host-endpoint username password ha-policy-body exchange-name queue-name) remaining-hosts (rest hosts)] - (when (and (nil? resp) - (pos? (count remaining-hosts))) + (when (and (nil? resp) + (pos? (count remaining-hosts))) (recur remaining-hosts)))))) (defn- declare-exchange [ch exchange] @@ -110,9 +113,10 @@ (defn- publish-internal [exchange message-payload expiration] (try - (with-open [ch (lch/open connection)] ;; it opens a connection everytime it publishes? - (lb/publish ch exchange "" (nippy/freeze (dissoc message-payload :headers)) - (properties-for-publish expiration (:headers message-payload)))) + (with-open [ch (lch/open connection)] + (let [rmq-msg (mwd/serialize-to-message-payload-proto (dissoc message-payload :headers)) + props (properties-for-publish expiration (:headers message-payload))] + (lb/publish ch exchange "" rmq-msg props))) false (catch AlreadyClosedException e (handle-network-exception e message-payload)) @@ -204,20 +208,20 @@ "This function return delay exchange name for retry when using flow without channel. It will return exchange name with retry count as suffix if exponential backoff enabled." [topic-entity message-payload] (let [{:keys [exchange-name]} (:delay (rabbitmq-config)) - exchange-name (util/prefixed-queue-name topic-entity exchange-name) - retry-count (-> (ziggurat-config) :retry :count)] + exchange-name (prefixed-queue-name topic-entity exchange-name) + retry-count (-> (ziggurat-config) :retry :count)] (if (= :exponential (-> (ziggurat-config) :retry :type)) (let [message-retry-count (:retry-count message-payload) backoff-exponent (get-backoff-exponent retry-count message-retry-count)] - (util/prefixed-queue-name exchange-name backoff-exponent)) + (prefixed-queue-name exchange-name backoff-exponent)) exchange-name))) (defn get-channel-delay-exchange-name "This function return delay exchange name for retry when using channel flow. It will return exchange name with retry count as suffix if exponential backoff enabled." [topic-entity channel message-payload] (let [{:keys [exchange-name]} (:delay (rabbitmq-config)) - exchange-name (util/prefixed-channel-name topic-entity channel exchange-name) - channel-retry-count (get-channel-retry-count topic-entity channel)] + exchange-name (prefixed-channel-name topic-entity channel exchange-name) + channel-retry-count (get-channel-retry-count topic-entity channel)] (if (= :exponential (channel-retry-type topic-entity channel)) (let [message-retry-count (:retry-count message-payload) exponential-backoff (get-backoff-exponent channel-retry-count message-retry-count)] @@ -256,23 +260,21 @@ (defn publish-to-channel-instant-queue [channel message-payload] (let [{:keys [exchange-name]} (:instant (rabbitmq-config)) - topic-entity (:topic-entity message-payload) - exchange-name (util/prefixed-channel-name topic-entity channel exchange-name)] + topic-entity (:topic-entity message-payload) + exchange-name (prefixed-channel-name topic-entity channel exchange-name)] (publish exchange-name message-payload))) (defn retry [{:keys [retry-count] :as message-payload}] (when (-> (ziggurat-config) :retry :enabled) (cond - (nil? retry-count) (publish-to-delay-queue (assoc message-payload :retry-count (dec (-> (ziggurat-config) :retry :count)))) - (pos? retry-count) (publish-to-delay-queue (assoc message-payload :retry-count (dec retry-count))) - (zero? retry-count) (publish-to-dead-queue (assoc message-payload :retry-count (-> (ziggurat-config) :retry :count)))))) + (or (nil? retry-count) (zero? retry-count)) (publish-to-dead-queue (assoc message-payload :retry-count (-> (ziggurat-config) :retry :count))) + (pos? retry-count) (publish-to-delay-queue (assoc message-payload :retry-count (dec retry-count)))))) (defn retry-for-channel [{:keys [retry-count topic-entity] :as message-payload} channel] (when (channel-retries-enabled topic-entity channel) (cond - (nil? retry-count) (publish-to-channel-delay-queue channel (assoc message-payload :retry-count (dec (get-channel-retry-count topic-entity channel)))) - (pos? retry-count) (publish-to-channel-delay-queue channel (assoc message-payload :retry-count (dec retry-count))) - (zero? retry-count) (publish-to-channel-dead-queue channel (assoc message-payload :retry-count (get-channel-retry-count topic-entity channel)))))) + (or (nil? retry-count) (zero? retry-count)) (publish-to-channel-dead-queue channel (assoc message-payload :retry-count (get-channel-retry-count topic-entity channel))) + (pos? retry-count) (publish-to-channel-delay-queue channel (assoc message-payload :retry-count (dec retry-count)))))) (defn- make-delay-queue [topic-entity] (let [{:keys [queue-name exchange-name dead-letter-exchange]} (:delay (rabbitmq-config)) @@ -330,7 +332,7 @@ (defn make-queues [routes] (when (is-connection-required?) (doseq [topic-entity (keys routes)] - (let [channels (util/get-channel-names routes topic-entity) + (let [channels (get-channel-names routes topic-entity) retry-type (retry-type)] (make-channel-queues channels topic-entity) (when (-> (ziggurat-config) :retry :enabled) diff --git a/src/ziggurat/middleware/default.clj b/src/ziggurat/middleware/default.clj index 385432e6..ad102ae7 100644 --- a/src/ziggurat/middleware/default.clj +++ b/src/ziggurat/middleware/default.clj @@ -1,10 +1,10 @@ (ns ziggurat.middleware.default (:require [protobuf.impl.flatland.mapdef :as protodef] - [sentry-clj.async :as sentry] [ziggurat.config :refer [get-in-config ziggurat-config]] [ziggurat.metrics :as metrics] - [ziggurat.sentry :refer [sentry-reporter]] - [ziggurat.util.error :refer [report-error]])) + [ziggurat.util.error :refer [report-error]] + [protobuf.core :as protobuf]) + (:import [com.ziggurat.proto MessagePayloadProto$MessagePayload])) (defn protobuf-struct->persistent-map [struct] "This functions converts a protobuf struct in to clojure persistent map recursively" @@ -33,6 +33,11 @@ {} fields))) +(defn serialize-to-message-payload-proto + [message] + (let [updated-message (update message :topic-entity name)] + (protobuf/->bytes (protobuf/create MessagePayloadProto$MessagePayload updated-message)))) + (defn deserialize-message "This function takes in the message(proto Byte Array) and the proto-class and deserializes the proto ByteArray into a Clojure PersistentHashMap. diff --git a/src/ziggurat/streams.clj b/src/ziggurat/streams.clj index b2f6ca30..acf65896 100644 --- a/src/ziggurat/streams.clj +++ b/src/ziggurat/streams.clj @@ -5,7 +5,7 @@ [ziggurat.config :refer [build-streams-config-properties get-in-config ziggurat-config]] [ziggurat.header-transformer :as header-transformer] [ziggurat.mapper :refer [mapper-func]] - [ziggurat.message-payload :refer [->MessagePayload]] + [ziggurat.message-payload :refer [mk-message-payload]] [ziggurat.metrics :as metrics] [ziggurat.timestamp-transformer :as timestamp-transformer] [ziggurat.tracer :refer [tracer]] @@ -137,7 +137,7 @@ (.asChildOf t parent-ctx)) (.start t))] (try - ((mapper-func handler-fn channels) (-> (->MessagePayload (:value message) topic-entity) + ((mapper-func handler-fn channels) (-> (mk-message-payload (:value message) topic-entity) (assoc :headers (:headers message)) (assoc :metadata (:metadata message)))) (finally diff --git a/test/com/gojek/test/proto/Example.java b/test/com/gojek/test/proto/Example.java new file mode 100644 index 00000000..29046208 --- /dev/null +++ b/test/com/gojek/test/proto/Example.java @@ -0,0 +1,2639 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: proto/example.proto + +package com.gojek.test.proto; + +public final class Example { + private Example() {} + 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 PhotoOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.gojek.test.proto.Photo) + com.google.protobuf.MessageOrBuilder { + + /** + * int32 id = 1; + */ + int getId(); + + /** + * string path = 2; + */ + java.lang.String getPath(); + /** + * string path = 2; + */ + com.google.protobuf.ByteString + getPathBytes(); + + /** + * bytes image = 6; + */ + com.google.protobuf.ByteString getImage(); + } + /** + * Protobuf type {@code com.gojek.test.proto.Photo} + */ + public static final class Photo extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.gojek.test.proto.Photo) + PhotoOrBuilder { + private static final long serialVersionUID = 0L; + // Use Photo.newBuilder() to construct. + private Photo(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Photo() { + id_ = 0; + path_ = ""; + image_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Photo( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + 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; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 8: { + + id_ = input.readInt32(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); + + path_ = s; + break; + } + case 50: { + + image_ = input.readBytes(); + 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 com.gojek.test.proto.Example.internal_static_com_gojek_test_proto_Photo_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.gojek.test.proto.Example.internal_static_com_gojek_test_proto_Photo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.gojek.test.proto.Example.Photo.class, com.gojek.test.proto.Example.Photo.Builder.class); + } + + public interface LabelOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.gojek.test.proto.Photo.Label) + com.google.protobuf.MessageOrBuilder { + + /** + * string item = 1; + */ + java.lang.String getItem(); + /** + * string item = 1; + */ + com.google.protobuf.ByteString + getItemBytes(); + + /** + * bool exists = 2; + */ + boolean getExists(); + } + /** + * Protobuf type {@code com.gojek.test.proto.Photo.Label} + */ + public static final class Label extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.gojek.test.proto.Photo.Label) + LabelOrBuilder { + private static final long serialVersionUID = 0L; + // Use Label.newBuilder() to construct. + private Label(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Label() { + item_ = ""; + exists_ = false; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Label( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + 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; + default: { + if (!parseUnknownFieldProto3( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + item_ = s; + break; + } + case 16: { + + exists_ = input.readBool(); + 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 com.gojek.test.proto.Example.internal_static_com_gojek_test_proto_Photo_Label_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.gojek.test.proto.Example.internal_static_com_gojek_test_proto_Photo_Label_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.gojek.test.proto.Example.Photo.Label.class, com.gojek.test.proto.Example.Photo.Label.Builder.class); + } + + public static final int ITEM_FIELD_NUMBER = 1; + private volatile java.lang.Object item_; + /** + * string item = 1; + */ + public java.lang.String getItem() { + java.lang.Object ref = item_; + 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(); + item_ = s; + return s; + } + } + /** + * string item = 1; + */ + public com.google.protobuf.ByteString + getItemBytes() { + java.lang.Object ref = item_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + item_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EXISTS_FIELD_NUMBER = 2; + private boolean exists_; + /** + * bool exists = 2; + */ + public boolean getExists() { + return exists_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getItemBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, item_); + } + if (exists_ != false) { + output.writeBool(2, exists_); + } + unknownFields.writeTo(output); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getItemBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, item_); + } + if (exists_ != false) { + size += com.google.protobuf.CodedOutputStream + .computeBoolSize(2, exists_); + } + 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 com.gojek.test.proto.Example.Photo.Label)) { + return super.equals(obj); + } + com.gojek.test.proto.Example.Photo.Label other = (com.gojek.test.proto.Example.Photo.Label) obj; + + boolean result = true; + result = result && getItem() + .equals(other.getItem()); + result = result && (getExists() + == other.getExists()); + result = result && unknownFields.equals(other.unknownFields); + return result; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ITEM_FIELD_NUMBER; + hash = (53 * hash) + getItem().hashCode(); + hash = (37 * hash) + EXISTS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( + getExists()); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.gojek.test.proto.Example.Photo.Label parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.gojek.test.proto.Example.Photo.Label parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.gojek.test.proto.Example.Photo.Label parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.gojek.test.proto.Example.Photo.Label parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.gojek.test.proto.Example.Photo.Label parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.gojek.test.proto.Example.Photo.Label parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.gojek.test.proto.Example.Photo.Label parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.gojek.test.proto.Example.Photo.Label 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 com.gojek.test.proto.Example.Photo.Label parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static com.gojek.test.proto.Example.Photo.Label 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 com.gojek.test.proto.Example.Photo.Label parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.gojek.test.proto.Example.Photo.Label parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.gojek.test.proto.Example.Photo.Label prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + 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 com.gojek.test.proto.Photo.Label} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.gojek.test.proto.Photo.Label) + com.gojek.test.proto.Example.Photo.LabelOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.gojek.test.proto.Example.internal_static_com_gojek_test_proto_Photo_Label_descriptor; + } + + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.gojek.test.proto.Example.internal_static_com_gojek_test_proto_Photo_Label_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.gojek.test.proto.Example.Photo.Label.class, com.gojek.test.proto.Example.Photo.Label.Builder.class); + } + + // Construct using com.gojek.test.proto.Example.Photo.Label.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + item_ = ""; + + exists_ = false; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.gojek.test.proto.Example.internal_static_com_gojek_test_proto_Photo_Label_descriptor; + } + + public com.gojek.test.proto.Example.Photo.Label getDefaultInstanceForType() { + return com.gojek.test.proto.Example.Photo.Label.getDefaultInstance(); + } + + public com.gojek.test.proto.Example.Photo.Label build() { + com.gojek.test.proto.Example.Photo.Label result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.gojek.test.proto.Example.Photo.Label buildPartial() { + com.gojek.test.proto.Example.Photo.Label result = new com.gojek.test.proto.Example.Photo.Label(this); + result.item_ = item_; + result.exists_ = exists_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.gojek.test.proto.Example.Photo.Label) { + return mergeFrom((com.gojek.test.proto.Example.Photo.Label)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.gojek.test.proto.Example.Photo.Label other) { + if (other == com.gojek.test.proto.Example.Photo.Label.getDefaultInstance()) return this; + if (!other.getItem().isEmpty()) { + item_ = other.item_; + onChanged(); + } + if (other.getExists() != false) { + setExists(other.getExists()); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.gojek.test.proto.Example.Photo.Label parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.gojek.test.proto.Example.Photo.Label) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object item_ = ""; + /** + * string item = 1; + */ + public java.lang.String getItem() { + java.lang.Object ref = item_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + item_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * string item = 1; + */ + public com.google.protobuf.ByteString + getItemBytes() { + java.lang.Object ref = item_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + item_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string item = 1; + */ + public Builder setItem( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + item_ = value; + onChanged(); + return this; + } + /** + * string item = 1; + */ + public Builder clearItem() { + + item_ = getDefaultInstance().getItem(); + onChanged(); + return this; + } + /** + * string item = 1; + */ + public Builder setItemBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + item_ = value; + onChanged(); + return this; + } + + private boolean exists_ ; + /** + * bool exists = 2; + */ + public boolean getExists() { + return exists_; + } + /** + * bool exists = 2; + */ + public Builder setExists(boolean value) { + + exists_ = value; + onChanged(); + return this; + } + /** + * bool exists = 2; + */ + public Builder clearExists() { + + exists_ = false; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFieldsProto3(unknownFields); + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.gojek.test.proto.Photo.Label) + } + + // @@protoc_insertion_point(class_scope:com.gojek.test.proto.Photo.Label) + private static final com.gojek.test.proto.Example.Photo.Label DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.gojek.test.proto.Example.Photo.Label(); + } + + public static com.gojek.test.proto.Example.Photo.Label getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser