Skip to content

Commit 6c430da

Browse files
fix: Add Documentation (#221)
* fix: Add javadoc to public classes. * fix: Reformat. * fix: Suggested docs changes. * fix: Fix mvn site issues.
1 parent f25077d commit 6c430da

35 files changed

+237
-31
lines changed

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/AdminClientSettings.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,24 @@
2424
import io.grpc.StatusException;
2525
import java.util.Optional;
2626

27+
/** Settings for construction a Pub/Sub Lite AdminClient. */
2728
@AutoValue
2829
public abstract class AdminClientSettings {
2930

3031
// Required parameters.
32+
33+
/**
34+
* The <a href="https://cloud.google.com/pubsub/lite/docs/locations">cloud region</a> to perform
35+
* admin operations for.
36+
*/
3137
abstract CloudRegion region();
3238

3339
// Optional parameters.
40+
41+
/** The retry settings for this client. */
3442
abstract RetrySettings retrySettings();
3543

44+
/** A stub to use to connect. */
3645
abstract Optional<AdminServiceBlockingStub> stub();
3746

3847
public static Builder newBuilder() {
@@ -43,13 +52,19 @@ public static Builder newBuilder() {
4352
@AutoValue.Builder
4453
public abstract static class Builder {
4554
// Required parameters.
55+
56+
/** The cloud region to perform admin operations for. */
4657
public abstract Builder setRegion(CloudRegion region);
4758

4859
// Optional parameters.
60+
61+
/** The retry settings for this client. */
4962
public abstract Builder setRetrySettings(RetrySettings retrySettings);
5063

64+
/** A stub to use to connect. */
5165
public abstract Builder setStub(AdminServiceBlockingStub stub);
5266

67+
/** Build the settings object. */
5368
public abstract AdminClientSettings build();
5469
}
5570

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/CloudRegion.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@
1919
import com.google.auto.value.AutoValue;
2020
import java.io.Serializable;
2121

22+
/** A wrapped string representing a Google Cloud region. */
2223
@AutoValue
2324
public abstract class CloudRegion implements Serializable {
2425
private static final long serialVersionUID = 6814654654L;
2526

27+
/** Construct a CloudRegion from a string. */
2628
public static CloudRegion of(String value) {
2729
return new AutoValue_CloudRegion(value);
2830
}
2931

32+
/** The string representing this region. */
3033
public abstract String value();
3134
}

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/CloudZone.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import io.grpc.StatusException;
2222
import java.io.Serializable;
2323

24+
/** A representation of a Google Cloud zone. */
2425
@AutoValue
2526
public abstract class CloudZone implements Serializable {
2627
private static final long serialVersionUID = 867184651465L;
@@ -29,8 +30,10 @@ public static CloudZone of(CloudRegion region, char zoneId) {
2930
return new AutoValue_CloudZone(region, zoneId);
3031
}
3132

32-
// Construct a CloudZone from a valid zone string. `zone` must be formatted as:
33-
// <location>-<direction><number>-<letter>
33+
/**
34+
* Construct a CloudZone from a valid zone string. `zone` must be formatted as:
35+
* &lt;location&gt;-&lt;direction&gt;&lt;number&gt;-&lt;letter&gt;
36+
*/
3437
public static CloudZone parse(String zone) throws StatusException {
3538
String[] splits = zone.split("-", -1);
3639
if (splits.length != 3) {
@@ -43,10 +46,13 @@ public static CloudZone parse(String zone) throws StatusException {
4346
return of(region, splits[2].charAt(0));
4447
}
4548

49+
/** The region this zone is in. */
4650
public abstract CloudRegion region();
4751

52+
/** The character identifier for this zone in this region. */
4853
public abstract char zoneId();
4954

55+
/** {@inheritDoc} */
5056
@Override
5157
public final String toString() {
5258
return String.format("%s-%c", region().value(), zoneId());

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.api.gax.retrying.RetrySettings;
2020
import org.threeten.bp.Duration;
2121

22+
/** Useful general constants for Pub/Sub Lite. */
2223
public class Constants {
2324
public static final RetrySettings DEFAULT_RETRY_SETTINGS =
2425
RetrySettings.newBuilder()

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/Endpoints.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
package com.google.cloud.pubsublite;
1818

19+
/** Constructs regional endpoints from a CloudRegion. */
1920
public final class Endpoints {
21+
/** Construct a regional endpoint from a CloudRegion. */
2022
public static String regionalEndpoint(CloudRegion region) {
2123
return region.value() + "-pubsublite.googleapis.com";
2224
}

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/ErrorCodes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.common.collect.ImmutableSet;
2020
import io.grpc.Status.Code;
2121

22+
/** Pub/Sub Lite retryable error codes. */
2223
public final class ErrorCodes {
2324
public static final ImmutableSet<Code> RETRYABLE_CODES =
2425
ImmutableSet.of(

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/LocationPath.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@
2121
import com.google.auto.value.AutoValue;
2222
import java.io.Serializable;
2323

24+
/**
25+
* A string wrapper representing a project and location. Should be structured like:
26+
*
27+
* <p>projects/&lt;project number&gt;/locations/&lt;cloud zone&gt;
28+
*/
2429
@AutoValue
2530
public abstract class LocationPath implements Serializable {
31+
/** The string value of this location path. */
2632
public abstract String value();
2733

34+
/** Construct a LocationPath from its string value. */
2835
public static LocationPath of(String value) {
2936
checkArgument(!value.isEmpty());
3037
return new AutoValue_LocationPath(value);

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/LocationPaths.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,29 @@
2222
import com.google.auto.value.AutoValue;
2323
import io.grpc.StatusException;
2424

25+
/** Helpers for constructing valid LocationPaths. */
2526
@AutoValue
2627
public abstract class LocationPaths {
2728
abstract ProjectNumber projectNumber();
2829

2930
abstract CloudZone zone();
3031

32+
/** Create a new LocationPath builder. */
3133
public static Builder newBuilder() {
3234
return new AutoValue_LocationPaths.Builder();
3335
}
3436

3537
@AutoValue.Builder
3638
public abstract static class Builder {
39+
/** The project number. */
3740
public abstract Builder setProjectNumber(ProjectNumber number);
3841

42+
/** The Google Cloud zone. */
3943
public abstract Builder setZone(CloudZone zone);
4044

4145
abstract LocationPaths autoBuild();
4246

47+
/** Build a new LocationPath. */
4348
public LocationPath build() {
4449
LocationPaths built = autoBuild();
4550
return LocationPath.of(
@@ -53,11 +58,13 @@ private static void checkSplits(String[] splits) throws StatusException {
5358
checkArgument(splits[2].equals("locations"));
5459
}
5560

61+
/** Check that the provided LocationPath is valid. */
5662
public static void check(LocationPath path) throws StatusException {
5763
ProjectNumber unusedProjectNumber = getProjectNumber(path);
5864
CloudZone unusedZone = getZone(path);
5965
}
6066

67+
/** Get the ProjectNumber from a LocationPath. */
6168
public static ProjectNumber getProjectNumber(LocationPath path) throws StatusException {
6269
String[] splits = path.value().split("/");
6370
checkSplits(splits);
@@ -68,6 +75,7 @@ public static ProjectNumber getProjectNumber(LocationPath path) throws StatusExc
6875
}
6976
}
7077

78+
/** Get the CloudZone from a LocationPath. */
7179
public static CloudZone getZone(LocationPath path) throws StatusException {
7280
String[] splits = path.value().split("/");
7381
checkSplits(splits);

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/Message.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,30 @@
2727
/** A user message. */
2828
@AutoValue
2929
public abstract class Message {
30+
/** The key for this message. All messages with the same key are routed to the same partition. */
3031
public abstract ByteString key();
3132

33+
/** The data payload for this message. */
3234
public abstract ByteString data();
3335

36+
/** A multimap of attributes for this message. */
3437
public abstract ImmutableListMultimap<String, ByteString> attributes();
3538

39+
/** The user-provided event time for this message. */
3640
public abstract Optional<Timestamp> eventTime();
3741

42+
/** Get a new builder for a message. */
3843
public static Builder builder() {
3944
return new AutoValue_Message.Builder()
4045
.setKey(ByteString.EMPTY)
4146
.setData(ByteString.EMPTY)
4247
.setAttributes(ImmutableListMultimap.of());
4348
}
4449

50+
/** Convert an existing message to a builder. */
4551
public abstract Builder toBuilder();
4652

53+
/** Convert this to a message proto. */
4754
public PubSubMessage toProto() {
4855
PubSubMessage.Builder builder = PubSubMessage.newBuilder();
4956
builder.setKey(key());
@@ -60,6 +67,7 @@ public PubSubMessage toProto() {
6067
return builder.build();
6168
}
6269

70+
/** Construct a message from a proto. */
6371
public static Message fromProto(PubSubMessage proto) {
6472
Message.Builder builder = Message.builder().setKey(proto.getKey()).setData(proto.getData());
6573
if (proto.hasEventTime()) {
@@ -77,14 +85,21 @@ public static Message fromProto(PubSubMessage proto) {
7785

7886
@AutoValue.Builder
7987
public abstract static class Builder {
88+
/**
89+
* The key for this message. All messages with the same key are routed to the same partition.
90+
*/
8091
public abstract Builder setKey(ByteString key);
8192

93+
/** The data payload for this message. */
8294
public abstract Builder setData(ByteString data);
8395

96+
/** A multimap of attributes for this message. */
8497
public abstract Builder setAttributes(ImmutableListMultimap<String, ByteString> attributes);
8598

99+
/** The user provided event time for this message. */
86100
public abstract Builder setEventTime(Timestamp eventTime);
87101

102+
/** Build a message. */
88103
public abstract Message build();
89104
}
90105
}

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/MessageTransformer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818

1919
import io.grpc.StatusException;
2020

21-
// A MessageTransformer details how to transform a message of one type to another. It is likely that
22-
// either FromT or ToT will be a Message on publish and SequencedMessage on subscribe.
21+
/**
22+
* A MessageTransformer details how to transform a message of one type to another. It is likely that
23+
* either FromT or ToT will be a Message on publish and SequencedMessage on subscribe.
24+
*/
2325
public interface MessageTransformer<FromT, ToT> {
26+
/** Transform one message type to another. */
2427
ToT transform(FromT from) throws StatusException;
2528
}

0 commit comments

Comments
 (0)