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

poll_for_updates discussion #52

Open
deweyjose opened this issue Dec 20, 2022 · 5 comments
Open

poll_for_updates discussion #52

deweyjose opened this issue Dec 20, 2022 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@deweyjose
Copy link

Describe the feature request

It would be helpful to understand the design decision not to automatically support execution of poll_for_updates.

Is the library trying to remain as agnostic as possible to different execution models - std::thread tokio async/await etc?

Or was there a total misunderstanding and we are able to configure the library to fetch updates?

Background

No response

Solution suggestions

No response

@deweyjose deweyjose added the enhancement New feature or request label Dec 20, 2022
@thomasheartman
Copy link
Contributor

That's a good question. I'm not entirely sure about the reasoning behind the design decisions in this library, but @rbtcollins would probably have some useful insights here. @sighphyre might also have some useful input.

@thomasheartman thomasheartman moved this from New to ext. contrib. / awaiting response in Issues and PRs Jan 9, 2023
@rbtcollins
Copy link
Collaborator

From the docs:
https://docs.rs/unleash-api-client/latest/unleash_api_client/#client-overview

"As the client specification requires sending background metrics to the API, you will need to arrange to call the poll_for_updates method from a thread as demonstrated in examples/threads.rs"

(And since it also supports async networking, you can do that from a tokio task or whatever as well if you like).

The example code on that page has this:

        futures::future::join(client.poll_for_updates(), async {
            // Ensure we have initial load of features completed
            Delay::new(Duration::from_millis(500)).await;
            assert_eq!(true, client.is_enabled(UserFeatures::default, None, false));
            // ... serve more requests
            client.stop_poll().await;
        }).await;
        Ok(())

which demonstrates both doing polling for updates, and doing a graceful shutdown of the poller - though thats not needed if you like you can just drop the tokio task.

@rbtcollins rbtcollins added documentation Improvements or additions to documentation and removed enhancement New feature or request labels Jan 10, 2023
@rbtcollins
Copy link
Collaborator

Perhaps I misunderstood the question?

@thomasheartman
Copy link
Contributor

Sorry for not responding sooner. I can't speak for the OP, but I interpreted it as "why do we have to set it up ourself" / "why doesn't the SDK do it automatically". The docs say you have to do it yourself, but it doesn't explicitly say why as far as I can tell. Presumably it's because you need an async runtime and the SDK doesn't pick one for you?

@michaelkanis-dmtech
Copy link

I would also like to know why the Rust client SDK requires you to setup the polling yourself. I have used the Unleash SDKs for other languages (Java, Python, Go) and none requires you to do that. It's always just: 1) create a client instance and 2) call isEnabled(). TBH, as an application developer I don't want to be bothered with setting up the details of a library like this.

Could the Rust SDK support this simpler usage, too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Status: ext. contrib. / awaiting response
Development

No branches or pull requests

4 participants