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

Persist since token periodically #209

Merged
merged 4 commits into from
Jul 19, 2023
Merged

Conversation

S7evinK
Copy link
Collaborator

@S7evinK S7evinK commented Jul 18, 2023

Q: should we make the duration configurable?

As per the comments in the code, we store the first since token immediately, after that, either after the last time we stored a token is > 1min OR there are ToDevice messages in the sync response.

Copy link
Member

@kegsay kegsay left a comment

Choose a reason for hiding this comment

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

LGTM, please add a test which mocks up the receiver and asserts that UpdateDeviceSince is:

  • called immediately the first time with the correct since value.
  • is not called for random events.
  • is called for to-device events.
  • is called after 1 minute (you'll need to mock this e.g var timeSince = func(t time.Time) time.Duration and then the test replaces timeSince with something that returns a high duration.

pid := PollerID{UserID: "@alice:localhost", DeviceID: "FOOBAR"}

syncResponses := make(chan *SyncResponse, 1)
accumulator, client := newMocks(func(authHeader, since string) (*SyncResponse, int, error) {
Copy link
Member

@kegsay kegsay Jul 19, 2023

Choose a reason for hiding this comment

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

Please check that client.DoSyncV2 is called with the correct since tokens.

@kegsay kegsay merged commit 9db1269 into main Jul 19, 2023
6 checks passed
@S7evinK S7evinK deleted the s7evink/persistsinceperiodically branch July 20, 2023 11:20
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