Skip to content

Commit

Permalink
fix: Add the ability to set UUID in AssignerSettings (#1296)
Browse files Browse the repository at this point in the history
* fix: Add the ability to set UUID in AssignerSettings

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
dpcollins-google and gcf-owl-bot[bot] authored Dec 19, 2022
1 parent 45b13c5 commit cade129
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ If you are using Maven, add this to your pom.xml file:
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-pubsublite:1.9.1'
implementation 'com.google.cloud:google-cloud-pubsublite:1.9.2'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-pubsublite" % "1.9.1"
libraryDependencies += "com.google.cloud" % "google-cloud-pubsublite" % "1.9.2"
```

## Authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ public abstract class AssignerSettings {

abstract PartitionAssignmentServiceClient serviceClient();

// Optional parameters.
abstract UUID uuid();

public static Builder newBuilder() {
return new AutoValue_AssignerSettings.Builder();
return new AutoValue_AssignerSettings.Builder().setUuid(UUID.randomUUID());
}

@AutoValue.Builder
Expand All @@ -48,15 +51,18 @@ public abstract static class Builder {

public abstract Builder setServiceClient(PartitionAssignmentServiceClient serviceClient);

// Optional parameters.
public abstract Builder setUuid(UUID uuid);

public abstract AssignerSettings build();
}

public Assigner instantiate() {
UUID uuid = UUID.randomUUID();
ByteBuffer uuidBuffer = ByteBuffer.allocate(16);
uuidBuffer.putLong(uuid.getMostSignificantBits());
uuidBuffer.putLong(uuid.getLeastSignificantBits());
logger.atInfo().log("Subscription %s using UUID %s for assignment.", subscriptionPath(), uuid);
uuidBuffer.putLong(uuid().getMostSignificantBits());
uuidBuffer.putLong(uuid().getLeastSignificantBits());
logger.atInfo().log(
"Subscription %s using UUID %s for assignment.", subscriptionPath(), uuid());

InitialPartitionAssignmentRequest initial =
InitialPartitionAssignmentRequest.newBuilder()
Expand Down

0 comments on commit cade129

Please sign in to comment.