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

snapshot engine in go #326

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

anthonpetrow
Copy link

@anthonpetrow anthonpetrow commented Aug 9, 2024

In our company, we tried to get involved in the hot method for a batch request, and our request began to be answered by clients with a timeout error. We carefully studied the query logic inside the repository and it turns out that inside the batch evaluates each flag in the loop and executes a query to the database each time, which increased our query execution time. We started thinking towards flipt-client-side, but we were afraid to include the ffi utility in the legacy php project. As a result, we decided to completely import the evaluation logic into our project in the go lang. Yes, it duplicates the logic of the main server, but I want to share the work done. Perhaps someone will find it useful

@anthonpetrow anthonpetrow requested a review from a team as a code owner August 9, 2024 13:14
@markphelps
Copy link
Contributor

Thanks for opening this PR @anthonpetrow !!

I think this is a great reference for anyone looking to do the same in their language of choice.

we were afraid to include the ffi utility in the legacy php project.

We've been thinking about this recently, particularly because FFI can be a bit daunting and doesn't work in all environments (at least the way that our client side evaluator is currently built, ex: #141 ).

One approach we are actively investigating is leaning further into WASM for the evaluation logic. Then using WASM runtimes in each of the languages that support it (Go is one) to call the evaluation functions.

Currently though, because WASM / WASI spec is not complete, and definitely not supported everywhere, we will have still perform the HTTP requests in the native language like we do in flipt-client-browser and then pass the data to the wasm engine as JSON.

I think we could use a lot of what you have done in this PR, but instead of re-implementing the evaluation logic in pure Go we could call into our WASM engine (after adding WASM runtime in Go also).

This would make the Go SDK cross-platform and we could then expand to other languages as well.

I'm going to open an issue to track native WASM support to get started, and will try to hack on this some this weekend.

@markphelps markphelps mentioned this pull request Aug 9, 2024
5 tasks
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