splitio / javascript-client

NodeJS and Browser SDK client for Split Software
https://split.io
Other
48 stars 36 forks source link

Feature request: custom storage (factory) #781

Open jamesarosen opened 11 months ago

jamesarosen commented 11 months ago

I'd like to use Vercel KV as my storage. It's an implementation of Redis, but it doesn't expose a Redis URL. Instead, there's a JavaScript client library that supports the same methods.

Ideally, there would be some contract, expressed as a TypeScript interface, for a custom storage. I'd then be able to pass in my own factory instead of "memory" or "redis".

const factory = SplitFactory({
  storage: () => new MyCustomVercelKVStorage(),
})

Currently, that's impossible because getStorage is closure-scoped, as is getModules, which calls it.

Some additional benefits of this approach:

jamesarosen commented 11 months ago

Ah! This example suggests the solution is to use PluggableStorage from the browser SDK.

jamesarosen commented 4 months ago

This issue seems relevant again now that this library's README says,

The JavaScript SDK is an isomorphic library for both Node.js and Web browser environments.

EmilianoSanchez commented 4 months ago

Yes @jamesarosen ,

As explained here, this package doesn't support custom storages yet :/.

Because of the benefits you mentioned, we plan to support it, but there is no ETA yet. Let's keep this issue open until we have a solution for it.