Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specify the ShardIterator where consumer should start reading from Horizon or Latest #53

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ private GetShardIteratorRequest buildIteratorShardRequest(final ShardPosition sh
.shardIteratorType(AT_TIMESTAMP)
.timestamp(shardPosition.timestamp());
break;
case LATEST:
shardRequestBuilder
.shardIteratorType(LATEST);
break;
}
return shardRequestBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ private ShardPosition(final String shardName, final String position, final Insta
this.startFrom = startFrom;
}

private ShardPosition(final String shardName) {
this.shardName = requireNonNull(shardName);
this.position = "";
this.timestamp = null;
this.startFrom = StartFrom.LATEST;
}

@Nonnull
public static ShardPosition fromHorizon(final @Nonnull String shardName) {
return new ShardPosition(shardName, "");
Expand All @@ -61,6 +68,11 @@ public static ShardPosition fromTimestamp(final @Nonnull String shardName,
return new ShardPosition(shardName, timestamp);
}

@Nonnull
public static ShardPosition fromLatest(final @Nonnull String shardName) {
return new ShardPosition(shardName);
}

@Nonnull
@JsonProperty
public String shardName() {
Expand Down