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

WASM Sdk #51

Closed
felipellrocha opened this issue Oct 23, 2023 · 8 comments
Closed

WASM Sdk #51

felipellrocha opened this issue Oct 23, 2023 · 8 comments
Labels
enhancement New feature or request Stale waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness.

Comments

@felipellrocha
Copy link

Is your feature request related to a problem? Please describe.
I have a project that is half react and half Rust+wasm32-unknown-unknown. I would like to use the Rust SDK on the wasm side.

Describe the solution you'd like
Import the SDK, it detects it's being compiled to wasm, it just works on the browser.

@cwaldren-ld
Copy link
Contributor

Hi @felipellrocha. Would you mind telling us a bit more about your exploration of compiling the SDK for the wasm target?

For example: have you tried this out already?
Is there anything in particular that isn't working?

@felipellrocha
Copy link
Author

Yeah, you have some dependencies that don't play well on wasm, Mio, in particular:

error[E0432]: unresolved import `crate::sys::IoSourceState`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/io_source.rs:12:5
   |
12 | use crate::sys::IoSourceState;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ no `IoSourceState` in `sys`

error[E0432]: unresolved import `crate::sys::tcp`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/listener.rs:15:17
   |
15 | use crate::sys::tcp::{bind, listen, new_for_addr};
   |                 ^^^ could not find `tcp` in `sys`

error[E0432]: unresolved import `crate::sys::tcp`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/stream.rs:13:17
   |
13 | use crate::sys::tcp::{connect, new_for_addr};
   |                 ^^^ could not find `tcp` in `sys`

error[E0433]: failed to resolve: could not find `Selector` in `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/poll.rs:300:18
    |
300 |             sys::Selector::new().map(|selector| Poll {
    |                  ^^^^^^^^ could not find `Selector` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:24:14
   |
24 |         sys::event::token(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:38:14
   |
38 |         sys::event::is_readable(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:43:14
   |
43 |         sys::event::is_writable(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:68:14
   |
68 |         sys::event::is_error(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:99:14
   |
99 |         sys::event::is_read_closed(&self.inner)
   |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:129:14
    |
129 |         sys::event::is_write_closed(&self.inner)
    |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:151:14
    |
151 |         sys::event::is_priority(&self.inner)
    |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:173:14
    |
173 |         sys::event::is_aio(&self.inner)
    |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:183:14
    |
183 |         sys::event::is_lio(&self.inner)
    |              ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `event` in `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:221:26
    |
221 |                     sys::event::debug_details(f, self.0)
    |                          ^^^^^ could not find `event` in `sys`

error[E0433]: failed to resolve: could not find `tcp` in `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/listener.rs:103:18
    |
103 | ...   sys::tcp::accept(inner).map(|(stream, addr)| (TcpStream::from_std(stream),...
    |            ^^^ could not find `tcp` in `sys`

error[E0433]: failed to resolve: could not find `udp` in `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/udp.rs:122:14
    |
122 |         sys::udp::bind(addr).map(UdpSocket::from_std)
    |              ^^^ could not find `udp` in `sys`

error[E0433]: failed to resolve: could not find `udp` in `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/udp.rs:544:14
    |
544 |         sys::udp::only_v6(&self.inner)
    |              ^^^ could not find `udp` in `sys`

error[E0412]: cannot find type `Selector` in module `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/poll.rs:254:20
    |
254 |     selector: sys::Selector,
    |                    ^^^^^^^^ not found in `sys`

error[E0412]: cannot find type `Selector` in module `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/poll.rs:688:44
    |
688 |     pub(crate) fn selector(&self) -> &sys::Selector {
    |                                            ^^^^^^^^ not found in `sys`

error[E0412]: cannot find type `Waker` in module `sys`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/waker.rs:79:17
   |
79 |     inner: sys::Waker,
   |                 ^^^^^ not found in `sys`
   |
help: consider importing one of these items
   |
1  + use core::task::Waker;
   |
1  + use crate::Waker;
   |
1  + use std::task::Waker;
   |
help: if you import `Waker`, refer to it directly
   |
79 -     inner: sys::Waker,
79 +     inner: Waker,
   |

error[E0433]: failed to resolve: could not find `Waker` in `sys`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/waker.rs:87:14
   |
87 |         sys::Waker::new(registry.selector(), token).map(|inner| Waker { inner })
   |              ^^^^^ could not find `Waker` in `sys`
   |
help: consider importing one of these items
   |
1  + use core::task::Waker;
   |
1  + use crate::Waker;
   |
1  + use std::task::Waker;
   |
help: if you import `Waker`, refer to it directly
   |
87 -         sys::Waker::new(registry.selector(), token).map(|inner| Waker { inner })
87 +         Waker::new(registry.selector(), token).map(|inner| Waker { inner })
   |

error[E0412]: cannot find type `Event` in module `sys`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:18:17
   |
18 |     inner: sys::Event,
   |                 ^^^^^ not found in `sys`
   |
help: consider importing this struct through its public re-export
   |
1  + use crate::event::Event;
   |
help: if you import `Event`, refer to it directly
   |
18 -     inner: sys::Event,
18 +     inner: Event,
   |

error[E0412]: cannot find type `Event` in module `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:187:55
    |
187 |     pub(crate) fn from_sys_event_ref(sys_event: &sys::Event) -> &Event {
    |                                                       ^^^^^ not found in `sys`
    |
help: consider importing this struct through its public re-export
    |
1   + use crate::event::Event;
    |
help: if you import `Event`, refer to it directly
    |
187 -     pub(crate) fn from_sys_event_ref(sys_event: &sys::Event) -> &Event {
187 +     pub(crate) fn from_sys_event_ref(sys_event: &Event) -> &Event {
    |

error[E0412]: cannot find type `Event` in module `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:191:41
    |
191 |             &*(sys_event as *const sys::Event as *const Event)
    |                                         ^^^^^ not found in `sys`
    |
help: consider importing this struct through its public re-export
    |
1   + use crate::event::Event;
    |
help: if you import `Event`, refer to it directly
    |
191 -             &*(sys_event as *const sys::Event as *const Event)
191 +             &*(sys_event as *const Event as *const Event)
    |

error[E0412]: cannot find type `Event` in module `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/event.rs:217:46
    |
217 |             struct EventDetails<'a>(&'a sys::Event);
    |                                              ^^^^^ not found in `sys`
    |
help: consider importing this struct through its public re-export
    |
1   + use crate::event::Event;
    |
help: if you import `Event`, refer to it directly
    |
217 -             struct EventDetails<'a>(&'a sys::Event);
217 +             struct EventDetails<'a>(&'a Event);
    |

error[E0412]: cannot find type `Events` in module `sys`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/events.rs:43:17
   |
43 |     inner: sys::Events,
   |                 ^^^^^^ not found in `sys`
   |
help: consider importing this struct through its public re-export
   |
1  + use crate::Events;
   |
help: if you import `Events`, refer to it directly
   |
43 -     inner: sys::Events,
43 +     inner: Events,
   |

error[E0433]: failed to resolve: could not find `Events` in `sys`
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/events.rs:94:25
   |
94 |             inner: sys::Events::with_capacity(capacity),
   |                         ^^^^^^ could not find `Events` in `sys`
   |
help: consider importing this struct through its public re-export
   |
1  + use crate::Events;
   |
help: if you import `Events`, refer to it directly
   |
94 -             inner: sys::Events::with_capacity(capacity),
94 +             inner: Events::with_capacity(capacity),
   |

error[E0412]: cannot find type `Events` in module `sys`
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/events.rs:189:47
    |
189 |     pub(crate) fn sys(&mut self) -> &mut sys::Events {
    |                                               ^^^^^^ not found in `sys`
    |
help: consider importing this struct through its public re-export
    |
1   + use crate::Events;
    |
help: if you import `Events`, refer to it directly
    |
189 -     pub(crate) fn sys(&mut self) -> &mut sys::Events {
189 +     pub(crate) fn sys(&mut self) -> &mut Events {
    |

error[E0425]: cannot find value `listener` in this scope
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/listener.rs:74:24
   |
74 |         set_reuseaddr(&listener.inner, true)?;
   |                        ^^^^^^^^ not found in this scope

error[E0425]: cannot find value `listener` in this scope
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/listener.rs:76:15
   |
76 |         bind(&listener.inner, addr)?;
   |               ^^^^^^^^ not found in this scope

error[E0425]: cannot find value `listener` in this scope
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/listener.rs:77:17
   |
77 |         listen(&listener.inner, 1024)?;
   |                 ^^^^^^^^ not found in this scope

error[E0425]: cannot find value `listener` in this scope
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/listener.rs:78:12
   |
78 |         Ok(listener)
   |            ^^^^^^^^ not found in this scope

error[E0425]: cannot find value `stream` in this scope
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/stream.rs:90:18
   |
90 |         connect(&stream.inner, addr)?;
   |                  ^^^^^^ not found in this scope

error[E0425]: cannot find value `stream` in this scope
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/stream.rs:91:12
   |
91 |         Ok(stream)
   |            ^^^^^^ not found in this scope

error[E0425]: cannot find function `set_reuseaddr` in this scope
  --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/listener.rs:74:9
   |
74 |         set_reuseaddr(&listener.inner, true)?;
   |         ^^^^^^^^^^^^^ not found in this scope

   Compiling futures-channel v0.3.28
error[E0599]: no method named `register` found for struct `IoSource<std::net::TcpListener>` in the current scope
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/listener.rs:146:20
    |
146 |         self.inner.register(registry, token, interests)
    |                    ^^^^^^^^ method not found in `IoSource<TcpListener>`
    |
   ::: /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/io_source.rs:62:1
    |
62  | pub struct IoSource<T> {
    | ---------------------- method `register` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `Source` defines an item `register`, perhaps you need to implement it
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/source.rs:75:1
    |
75  | pub trait Source {
    | ^^^^^^^^^^^^^^^^

error[E0599]: no method named `reregister` found for struct `IoSource<std::net::TcpListener>` in the current scope
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/listener.rs:155:20
    |
155 |         self.inner.reregister(registry, token, interests)
    |                    ^^^^^^^^^^ method not found in `IoSource<TcpListener>`
    |
   ::: /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/io_source.rs:62:1
    |
62  | pub struct IoSource<T> {
    | ---------------------- method `reregister` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `Source` defines an item `reregister`, perhaps you need to implement it
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/source.rs:75:1
    |
75  | pub trait Source {
    | ^^^^^^^^^^^^^^^^

error[E0599]: no method named `deregister` found for struct `IoSource<std::net::TcpListener>` in the current scope
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/listener.rs:159:20
    |
159 |         self.inner.deregister(registry)
    |                    ^^^^^^^^^^ method not found in `IoSource<TcpListener>`
    |
   ::: /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/io_source.rs:62:1
    |
62  | pub struct IoSource<T> {
    | ---------------------- method `deregister` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `Source` defines an item `deregister`, perhaps you need to implement it
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/source.rs:75:1
    |
75  | pub trait Source {
    | ^^^^^^^^^^^^^^^^

error[E0599]: no method named `register` found for struct `IoSource<std::net::TcpStream>` in the current scope
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/stream.rs:325:20
    |
325 |         self.inner.register(registry, token, interests)
    |                    ^^^^^^^^ method not found in `IoSource<TcpStream>`
    |
   ::: /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/io_source.rs:62:1
    |
62  | pub struct IoSource<T> {
    | ---------------------- method `register` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `Source` defines an item `register`, perhaps you need to implement it
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/source.rs:75:1
    |
75  | pub trait Source {
    | ^^^^^^^^^^^^^^^^

error[E0599]: no method named `reregister` found for struct `IoSource<std::net::TcpStream>` in the current scope
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/stream.rs:334:20
    |
334 |         self.inner.reregister(registry, token, interests)
    |                    ^^^^^^^^^^ method not found in `IoSource<TcpStream>`
    |
   ::: /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/io_source.rs:62:1
    |
62  | pub struct IoSource<T> {
    | ---------------------- method `reregister` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `Source` defines an item `reregister`, perhaps you need to implement it
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/source.rs:75:1
    |
75  | pub trait Source {
    | ^^^^^^^^^^^^^^^^

error[E0599]: no method named `deregister` found for struct `IoSource<std::net::TcpStream>` in the current scope
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/tcp/stream.rs:338:20
    |
338 |         self.inner.deregister(registry)
    |                    ^^^^^^^^^^ method not found in `IoSource<TcpStream>`
    |
   ::: /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/io_source.rs:62:1
    |
62  | pub struct IoSource<T> {
    | ---------------------- method `deregister` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `Source` defines an item `deregister`, perhaps you need to implement it
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/source.rs:75:1
    |
75  | pub trait Source {
    | ^^^^^^^^^^^^^^^^

   Compiling crossbeam-epoch v0.9.15
error[E0599]: no method named `register` found for struct `IoSource<std::net::UdpSocket>` in the current scope
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/udp.rs:622:20
    |
622 |         self.inner.register(registry, token, interests)
    |                    ^^^^^^^^ method not found in `IoSource<UdpSocket>`
    |
   ::: /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/io_source.rs:62:1
    |
62  | pub struct IoSource<T> {
    | ---------------------- method `register` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `Source` defines an item `register`, perhaps you need to implement it
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/source.rs:75:1
    |
75  | pub trait Source {
    | ^^^^^^^^^^^^^^^^

error[E0599]: no method named `reregister` found for struct `IoSource<std::net::UdpSocket>` in the current scope
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/udp.rs:631:20
    |
631 |         self.inner.reregister(registry, token, interests)
    |                    ^^^^^^^^^^ method not found in `IoSource<UdpSocket>`
    |
   ::: /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/io_source.rs:62:1
    |
62  | pub struct IoSource<T> {
    | ---------------------- method `reregister` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `Source` defines an item `reregister`, perhaps you need to implement it
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/source.rs:75:1
    |
75  | pub trait Source {
    | ^^^^^^^^^^^^^^^^

error[E0599]: no method named `deregister` found for struct `IoSource<std::net::UdpSocket>` in the current scope
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/net/udp.rs:635:20
    |
635 |         self.inner.deregister(registry)
    |                    ^^^^^^^^^^ method not found in `IoSource<UdpSocket>`
    |
   ::: /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/io_source.rs:62:1
    |
62  | pub struct IoSource<T> {
    | ---------------------- method `deregister` not found for this struct
    |
    = help: items from traits can only be used if the trait is implemented and in scope
note: `Source` defines an item `deregister`, perhaps you need to implement it
   --> /Users/fllr/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mio-0.8.8/src/event/source.rs:75:1
    |
75  | pub trait Source {
    | ^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0412, E0425, E0432, E0433, E0599.
For more information about an error, try `rustc --explain E0412`.

@cwaldren-ld
Copy link
Contributor

cwaldren-ld commented Oct 23, 2023

It appears mio is a dependency of tokio, but perhaps the bigger issue is that tokio doesn't have stable WASM support (at least from a quick search - I haven't researched thoroughly yet.)

tokio-rs/tokio#4827

We use an async runtime in the SDK to handle the Server-Sent-Event connection that the SDK uses to receive feature flag data from LaunchDarkly, as well as send analytic events back to LaunchDarkly.

Might it be possible for you to use the React SDK and pass the flag values to the Rust component?

In any case, I will file this as a feature request.

Filed internally as 222204.

@cwaldren-ld cwaldren-ld added the enhancement New feature or request label Oct 23, 2023
@felipellrocha
Copy link
Author

Right. Not all of tokio supports wasm yet, and the parts that do aren't very useful. The thing about wasm32-unknown-unknown is that it provides its own async runtime, so you don't really need tokio that much anyway. In addition, the browser's api basically match tokio's async runtime if you were to use the single-threaded version.

I guess that is possible, just not desirable. Do you guys support a http based api? Because fetch is available in wasm, as well as reqwest if I'm not mistaken. SSE might not be directly supported by reqwest, but I'm certain that wasm-bindgen supports it (https://docs.rs/wasm-bindgen/latest/wasm_bindgen/), and, if so, I'd be willing to write that and contribute that back.

@cwaldren-ld
Copy link
Contributor

cwaldren-ld commented Oct 24, 2023

.. In addition, the browser's api basically match tokio's async runtime if you were to use the single-threaded version. I guess that is possible, just not desirable.

Does this mean the browser API actually implements tokio traits/methods? How does that actually look? Otherwise we'd need to do work to make our usage of tokio pluggable.

As for "not desirable", if you're referring to the single-threadedness aspect, in theory parallelism isn't required for most SDK usage. Async on a single thread is fine.

Do you guys support a http based api?

All of our networking takes place over HTTP, so I'm not sure what you're referring to. Let me know and I can clarify.

We don't use reqwest. The SDK uses a basic hyper client for "polling" mode (SDK fetches data on an interval), and our Eventsource Client in "streaming" mode (SDK receives data updates asynchronously.)

Finally, the Rust Server SDK is likely not appropriate for a browser environment - you'd want a client-side SDK. It's possible your use-case warrants it though, but it would mean exposing a server-side SDK key.

@felipellrocha
Copy link
Author

felipellrocha commented Oct 24, 2023

Ah, right. I'm looking for a client-side SDK.

Does this mean the browser API actually implements tokio traits/methods?

I think it implements the standard Futures api, so it should mostly be compatible. The thing is that if you use #[tokio::main(flavor = "current_thread")] to start your work, the API should basically be the same.

Let me know and I can clarify.

I meant if there were a set of http endpoint I could hit to query for the data I need. I wouldn't need polling at the moment either, just a basic checking of flags at initialization would suffice.

@cwaldren-ld
Copy link
Contributor

I meant if there were a set of http endpoint I could hit to query for the data I need.

There is - it's what our client-side SDKs use in polling mode (you don't need to poll on an interval, you could just make one request.) There's no public specs for it, but you're welcome to look at existing SDKs.

For example, this (.NET) or this (C++) could be starting points to receiving the evaluated flag payloads.

For testing, you might use a CURL like:

curl https://clientsdk.launchdarkly.com/msdk/evalx/contexts/$yourBase64EncodedContextJSON -H "Authorization: $yourMobileKey"

@cwaldren-ld cwaldren-ld added the waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness. label Nov 17, 2023
Copy link
Contributor

This issue is marked as stale because it has been open for 30 days without activity. Remove the stale label or comment, or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label Dec 18, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Stale waiting for feedback Indicates LaunchDarkly is waiting for customer feedback before issue is closed due to staleness.
Projects
None yet
Development

No branches or pull requests

2 participants