Skip to content

Expose a subscription-based API #30

@aalexandrov

Description

@aalexandrov

Is your feature request related to a problem? Please describe.

The SDK currently only exposes a based polling API. The only way to continuously monitor for changes in feature flags for a specific user / context is to periodically poll the Client for changes.

Describe the solution you'd like

It would be great to have a subscribe API in the SDK, when I would be able to do something like

ld_client.subscribe(&ld_ctx, handler)

and pass a handler that is called to handle Vec<FeatureUpdate> events. AFAICT this approximately the way the internal event source client works, so it shouldn't be too hard to implement this.

Describe alternatives you've considered

For example, at Materialize we use the following loop

let mut params = SynchronizedParameters::default();
loop {
    backend.pull(&mut params).await;
    if frontend.pull(&mut params) {
        backend.push(&mut params).await;
    }
    interval.tick().await;
}

where the frontend.pull makes the following call to ld_client: ld::Client using the ld_user: ld::User context.

self.ld_client.variation(&self.ld_user, flag_name, params.get(param_name));

Additional context

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions