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

refactor(typesense): remove unused exists checks #847

Merged
merged 2 commits into from
Aug 5, 2024

Conversation

saibotk
Copy link
Contributor

@saibotk saibotk commented Jul 12, 2024

In #820 we introduced an exists check method, which then lead to static state issues as described in #845

Those where addressed in #846

But now that the function always double-checks the existence, we can remove the exists check entirely and only rely on the Typesense server response for this state.

This "fixes" issues where the server already has a collection and the client would try to recreate it. E.g. when it has flushed the index and another process or worker then creates the collection.

@saibotk
Copy link
Contributor Author

saibotk commented Jul 12, 2024

@tharropoulos could you review this, just to be sure?

@saibotk saibotk force-pushed the 10.x branch 2 times, most recently from 20e4507 to ed0c5e3 Compare July 12, 2024 11:50
@saibotk
Copy link
Contributor Author

saibotk commented Jul 12, 2024

We could even remove the
$collection->setExists(true)
after creation, or i would also need to add $collection->setExists(true) right before returning the existing collection, to be sure that this field is set.

What are the plans regarding the exists field in the typesense sdk?

EDIT: Updated my code to also set the exists field when the server has the collection to be 100% correct.

In laravel#820 we introduced an exists check method, which then lead to static state issues as described in laravel#845

Those where addressed in laravel#846

But now that the function always double-checks the existence, we can remove the exists check entirely and only rely on the Typesense server response for this state.

This "fixes" issues where the server already has a collection and the client would try to recreate it. E.g. when it has flushed the index and another process or worker then creates the collection.
@taylorotwell taylorotwell marked this pull request as draft July 12, 2024 14:06
@tharropoulos
Copy link
Contributor

Thanks for iterating upon the PR! I'll have to check it first thing on Monday, as I'm away from my laptop for this weekend. I'll get back to you as soon as I can

@tharropoulos
Copy link
Contributor

Looking back on it, the verbosity used on the previous PR might be overkill, and after spending some time messing with it, it seems to work just fine.

CC: @jasonbosco could you also take a look at the code yourself? Looks just fine to me

@saibotk
Copy link
Contributor Author

saibotk commented Aug 5, 2024

I feel like this is pretty much ready otherwise, so i will mark this as ready :)

@saibotk saibotk marked this pull request as ready for review August 5, 2024 06:24
@taylorotwell taylorotwell merged commit d58e16f into laravel:10.x Aug 5, 2024
13 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.

3 participants