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

Offline mode in server side SDKs #2024

Open
6 of 9 tasks
matthewelwell opened this issue Mar 14, 2023 · 8 comments
Open
6 of 9 tasks

Offline mode in server side SDKs #2024

matthewelwell opened this issue Mar 14, 2023 · 8 comments
Assignees
Labels
feature New feature or request sdk Issues related to the SDKs
Milestone

Comments

@matthewelwell
Copy link
Contributor

matthewelwell commented Mar 14, 2023

Each of the Flagsmith server side SDKs should offer a way to have them function in 'offline mode'. By providing a JSON document of flags / an environment, the SDK should behave exactly as it does in local evaluation mode, however, using the static JSON document that should be bundled in the SDK itself.

This will need to be implemented in all of our serverside SDKs.

To implement:

  • Python (Kim)
  • Java
  • Go (Gagan)
  • Rust (Gagan)
  • PHP
  • NodeJS (Novak)
  • Ruby (Zach)
  • Elixir
  • .NET (Novak)
@matthewelwell matthewelwell changed the title Offline mode in SDKs Offline mode in server side SDKs Mar 14, 2023
@dabeeeenster dabeeeenster added the sdk Issues related to the SDKs label Apr 6, 2023
@matthewelwell
Copy link
Contributor Author

This logic has been implemented already in the client side JS SDK but here we're specifying that we only want to add it to the server side SDKs.

The question, I guess, is whether we want to implement this in more SDKs than server side SDKs. Would this functionality be useful for e.g. Kotlin, Swift, Flutter?

Related issue #1655

@matthewelwell
Copy link
Contributor Author

Once question here is whether, for server side SDKs, they should be able to handle segmentation as well in offline mode. I would argue that they should be able to. This would mean that this change could simply be that the environment document should be able to be read from the file system, rather than only from the API.

Thoughts @khvn26 @gagantrivedi @dabeeeenster ?

@dabeeeenster
Copy link
Contributor

Yep this seems like a simple approach that would work

@matthewelwell
Copy link
Contributor Author

2 implementation approaches here:

Flagsmith/flagsmith-python-client#50
Flagsmith/flagsmith-python-client#51

I think the single client class is slightly neater, but does technically break certain software engineering rules about only having a single purpose. A lot of the arguments passed to the constructor become redundant when using offline mode.

There is perhaps an argument to say, however, that the offline handler shouldn't be restricted to 'offline mode' and that it should be possible to use it instead of the default handler. In which case, the single client class is certainly the correct approach.

@dabeeeenster
Copy link
Contributor

How about making api_url optional and configuring the file path in the handler instance, and adding an option to fall back to offline not just when api_url is None but e.g. in case of network errors?

@matthewelwell
Copy link
Contributor Author

Python reference implementation is here: Flagsmith/flagsmith-python-client#50

@matthewelwell
Copy link
Contributor Author

@novakzaballa @gagantrivedi @zachaysan can you add the docs for the SDKs that you worked on for this. Reference PR for the docs is here.

@zachaysan
Copy link
Contributor

@matthewelwell Added the ruby ones in this PR: #3677

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request sdk Issues related to the SDKs
Projects
Status: In Progress Q1 2024
Development

No branches or pull requests

6 participants