Skip to content

[MMB-200] Implement cursor offsets rather than intervals #105

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

Merged
merged 1 commit into from
Aug 11, 2023

Conversation

surminus
Copy link
Collaborator

@surminus surminus commented Aug 8, 2023

Instead of calculating an even interval based upon the length of the buffer and the batchtime, instead pass along movement offsets as part of the message, and replay these offsets as part of the dispensing.

This ensures you get a more accurate representation of cursor movements.

The first offset is also 0, which removes the slight delay that was present in the original implementation, since the calculated interval was always the same.

Since we are immediately invoking the all the data in the buffer to create the timeouts, we can simplify the code to always just use
whatever data is present in the buffer as the gate to whether we should call emitFromBatch(). This means we can remove the logic related to handlerRunning.

Due to the way we are immediately processing the buffer, it means we cannot test in the same way we did previously, so tests have been amended to accommodate this.

Testing

Before

5

current-2023-08-10_17-26-05

15

current-2023-08-10_17-28-20

25

current-2023-08-10_17-31-25

After

5

intervals-2023-08-10_17-13-55

15

intervals-2023-08-10_17-15-50

25

intervals-2023-08-10_17-21-00

@surminus surminus force-pushed the laura-positional-batching branch from 93b71a0 to abf8599 Compare August 8, 2023 11:16
@surminus surminus force-pushed the laura-positional-batching branch 5 times, most recently from 3a67f27 to 0f71ac9 Compare August 10, 2023 14:28
@surminus surminus changed the title Implement cursor offsets rather than intervals [MMB-200] Implement cursor offsets rather than intervals Aug 10, 2023
@surminus surminus marked this pull request as ready for review August 10, 2023 14:29
Instead of calculating an even interval based upon the length of the
buffer and the batchtime, instead pass along movement offsets as part of
the message, and replay these offsets as part of the dispensing.

This ensures you get a more accurate representation of cursor movements.

The first offset is also 0, which removes the slight delay that was
present in the original implementation, since the calculated interval
was always the same.

Since we are immediately invoking the all the data in the buffer to
create the timeouts, we can simplify the code to always just use
whatever data is present in the buffer as the gate to whether we should
call `emitFromBatch()`. This means we can remove the logic related to
`handlerRunning`.

Due to the way we are immediately processing the buffer, it means we
cannot test in the same way we did previously, so tests have been
amended to accomodate this.
@surminus surminus force-pushed the laura-positional-batching branch from 0f71ac9 to 1a06c7e Compare August 11, 2023 09:59
@surminus surminus merged commit b5b932f into main Aug 11, 2023
@surminus surminus deleted the laura-positional-batching branch August 11, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants