Skip to content

Conversation

@FGasper
Copy link
Collaborator

@FGasper FGasper commented Nov 12, 2025

Previously the code maintained:

  • an Eventual for the error in persisting rechecks
  • an Eventual for the error in reading changes
  • an empty channel to indicate when the change reader is done

This is overly complex.

This changeset simplifies the above. Now there is a single Eventual that holds the final status of both readers & both persistors. Together the reader & persistor threads are called “change handling”.

This also fixes a small bug in Eventual: previously it was impossible to store a nil value because Eventual was implemented via Option. Now it’s possible to store nil.

@FGasper FGasper changed the title REP-6804 Simplify change handling logic. REP-6804 Simplify change handling logic Nov 12, 2025
@FGasper FGasper requested a review from tdq45gj November 12, 2025 18:11
Comment on lines +38 to +42
select {
case <-e.ready:
return e.val
default:
panic("Eventual's Get() called before value was ready.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that Eventual can only be read once per write. The comment says it's like context.Context’s Done() and Err(), is that changed with this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a test that confirms that a 2nd time works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It’s not changed … I added a test that confirms that a 2nd read works.

@FGasper FGasper requested a review from tdq45gj November 12, 2025 20:35
Copy link
Collaborator

@tdq45gj tdq45gj left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@FGasper FGasper merged commit 2325945 into mongodb-labs:main Nov 12, 2025
195 of 196 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants