Skip to content

Commit

Permalink
samples: add some comments (#538)
Browse files Browse the repository at this point in the history
* samples: add some comments

* skil line length check in generated file

* shorten paths
  • Loading branch information
anguillanneuf committed Feb 25, 2021
1 parent d8728e9 commit 8e4277f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion samples/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
<suppress checks="WhitespaceAroundCheck" files="StateProto.java"/>
<suppress checks="IllegalTokenTextCheck" files="StateProto.java"/>
<suppress checks="ParameterNameCheck" files="State.java"/>
<suppress checks="LineLengthCheck" files="State.java"/>
<suppress checks="LineLengthCheck" files="State.java|StateProto.java"/>
</suppressions>
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void createAvroSchemaExample(String projectId, String schemaId, St
projectName,
Schema.newBuilder()
.setName(schemaName.toString())
.setType(com.google.pubsub.v1.Schema.Type.AVRO)
.setType(Schema.Type.AVRO)
.setDefinition(avscSource)
.build(),
schemaId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void publishAvroRecordsExample(String projectId, String topicId)
encoding = topicAdminClient.getTopic(topicName).getSchemaSettings().getEncoding();
}

// Create an object of an avro-tools-generated class.
// Instantiate an avro-tools-generated class defined in `us-states.avsc`.
State state = State.newBuilder().setName("Alaska").setPostAbbr("AK").build();

Publisher publisher = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void publishProtobufMessagesExample(String projectId, String topic

Publisher publisher = null;

// Create an object of an avro-tools-generated class.
// Instantiate a protoc-generated class defined in `us-states.proto`.
State state = State.newBuilder().setName("Alaska").setPostAbbr("AK").build();

block:
Expand Down
12 changes: 12 additions & 0 deletions samples/snippets/src/main/java/utilities/State.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@
*
* <p>DO NOT EDIT DIRECTLY
*/

/**
* This file is created using Avro tools.
*
* To download, visit https://avro.apache.org/releases.html#Download
*
* Run the following command from the `samples/snippets` directory to
* generate this class:
*
*`java -jar /location/to/your/avro-tools-1.10.1.jar compile schema src/main/resources/us-states.avsc src/main/java/`
*/

package utilities;

import org.apache.avro.message.BinaryMessageDecoder;
Expand Down
11 changes: 11 additions & 0 deletions samples/snippets/src/main/java/utilities/StateProto.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: us-states.proto

/**
* This file is created using protoc.
*
* To download, visit https://developers.google.com/protocol-buffers/docs/downloads
*
* Run the following command from the `samples/snippets` directory to
* generate this class:
*
*`protoc --proto_path=src/main/resources/ --java_out=src/main/java/ src/main/resources/us-states.proto`
*/

package utilities;

public final class StateProto {
Expand Down

0 comments on commit 8e4277f

Please sign in to comment.