Skip to content

Change SyncUntil to SyncUntilArray#246

Closed
ShadowJonathan wants to merge 4 commits intomatrix-org:masterfrom
ShadowJonathan:syncuntilarray
Closed

Change SyncUntil to SyncUntilArray#246
ShadowJonathan wants to merge 4 commits intomatrix-org:masterfrom
ShadowJonathan:syncuntilarray

Conversation

@ShadowJonathan
Copy link
Contributor

@ShadowJonathan ShadowJonathan commented Dec 1, 2021

Fixes #245

Turns out i actually do need a SyncUtil as described above (for SYN-627, I need to receive events from different rooms and log them individually as they come in, I need to wait for and process an arbitrary value), so just I'll rename this alongside it.

I'm refactoring this in a seperate PR instead of the same PR for SYN-627, because this PR would be easier to review comparatively when bundled with the other helper function changes.

}

// Internal function helping both SyncUntil and SyncUntilArray with some logging coordination upon failure
func (c *CSAPI) syncUntilInternal(t *testing.T, since, filter, key string, wasFailed, timedOut *bool, checkCounter *int, check func(gjson.Result) bool) {
Copy link
Contributor Author

@ShadowJonathan ShadowJonathan Dec 1, 2021

Choose a reason for hiding this comment

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

This function signature is a bit bonkers, but essentially, most of these are used by SyncUntilArray to "feed back" the values.

Its used in its defer'd function (as t.Fatalf just stops the goroutine like a panic and runs all defers up the stack, and i wanted to separate SyncUntil and SyncUntilArray functionality.)

checkCounter is also artificially incremented in SyncUntilArray so that it matches the total amount of check calls it has done for elements in the arrays it finds.

@kegsay kegsay mentioned this pull request Dec 9, 2021
@kegsay
Copy link
Member

kegsay commented Dec 10, 2021

#272

@kegsay kegsay closed this Dec 10, 2021
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.

[nit] SyncUntil does not mention in its name it only matches key on arrays

2 participants