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

Persistent streams #347

Merged
merged 27 commits into from
Jul 2, 2024
Merged

Persistent streams #347

merged 27 commits into from
Jul 2, 2024

Conversation

MGathier
Copy link
Contributor

No description provided.

private final int segments;
private final String sequencingPolicyName;
private final List<String> sequencingPolicyParameters;
private final int initialPosition;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Position should be a long

* or to only sent progress information after a number of processed events.
* @param token the last processed token for this segment
*/
void acknowledge(long token);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when the client cannot send the ack to the server, for example when the connection is lost? Should we return a CompletableFuture to... ehhh... ack the ack?


import java.util.List;

public class PersistedStreamProperties {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the classname. Should be PersistentStreamProperties

* created with the properties specified in {@code creationProperties}.
* @param streamId the unique identification of a persistent stream
* @param creationProperties properties to initialize the persistent stream if it does not exist yet
* @return a PersistedStream streaming events per segment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PersistedStream -> PersistentStream



/**
* Deletes a persistent stream.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps explicitly mention that this command will also return normally if the stream does not exist (if that's the way it actually behaves, of course)

* @param segments the requested number of segments for the persistent stream
* @return a CompletableFuture that completes when the persistent stream is updated
*/
CompletableFuture<Void> setPersistentStreamSegments(String streamId, Integer segments);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an Integer, rather than an int? Is null an option somehow?

* Returns a list of persistent streams with the connected client per segment.
* @return a list of persistent streams
*/
CompletableFuture<List<StreamConnections>> persistentStreamConnections();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this become potentially very long? What about returning the connections for a given streamId? Then the persistentStreams() call can be used to retrieve all ID's, and the details can be fetched for those that are relevant.

private final long initialPosition;
private final String filter;

public PersistedStreamProperties(String streamName, int segments, String sequencingPolicyName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Javadoc is missing on this class.

Is 0 a valid value for segments? If not, would be good to validate that.

import java.util.concurrent.atomic.AtomicReference;
import java.util.function.LongConsumer;

public class BufferedPersistentStreamSegment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason this class doesn't extend the AbstractBufferedStream?


@BeforeEach
void setup() throws ExecutionException, InterruptedException {
AxonServerConnectionFactory connectionFactory = AxonServerConnectionFactory.forClient("demo",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test seems to assume AxonServer is running on port 8124 to run. Could we use testcontainers instead?

.build()).get(1, TimeUnit.SECONDS);

long last = eventChannel.getLastToken().get();
Thread.sleep(2000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an assertWithin in the AssertUtils class which would prevent the need for arbitrary sleeps.

There don't seem to be any assertions in this test either.

let client control flow of events for a persistent stream.
let client control flow of events for a persistent stream.
Copy link
Contributor

@smcvb smcvb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bunch of remarks that would clean up the new code before we merge it.

pom.xml Outdated Show resolved Hide resolved

/**
* Opens the persistent stream identified by {@code streamId}. Fails if the stream does not exist.
* @param streamId the unique identification of a persistent stream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all parameters are named in the JavaDoc.

return InitializationProperties.newBuilder()
.setInitialPosition(creationProperties.initialPosition())
.setSegments(creationProperties.segments())
.setStreamName(nonNullOrDefault(creationProperties.streamName(),""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An empty String as the Stream name seems rather useless to me. Wouldn't a shortened UUID better fit the bill if nothing's provided?

…fter a close request

wait for segments to complete the active batch on stopping the application
@MGathier MGathier merged commit c270a48 into master Jul 2, 2024
3 of 5 checks passed
@MGathier MGathier deleted the persisted-streams branch July 2, 2024 13:12
Copy link
Contributor

@smcvb smcvb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concerns have been addressed, hence I'm approving this pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants