Comments (7)
I tried to implement Drop
for RelayPool
but this cause many issues in a multi-threads env (like https://github.com/coinstr/coinstr) where the Client
is cloned and dropped many times.
For now the only way to completely shutdown the client is to exit from the app (the threads will drop) or by calling the shutdown
method.
from nostr.
An alternative to shutdown
is the stop
method: it allow to re-start a previously constructed Client
(anyway it must be called manually) by calling the start
method.
from nostr.
Just something to kill the connections on drop would be nice, have run into the problem multiple times on accident
from nostr.
Maybe you can wrap the Client
:
pub struct CustomClient {
inner: Client
}
impl Drop for CustomClient {
fn drop(&mut self) {
let client = self.clone();
async_utility::thread::spawn(async move {
client.shutdown().await.unwrap();
});
}
}
I can't implement the Drop
because if a user do this
let client = self.clone();
thread::spawn(async move {
// use client and then drop
});
the client shutdown everywhere.
from nostr.
Otherwise, I'll try to add a new filed in Options
, like shutdown_on_drop: bool
(by default will be disabled).
If you'll initialize the Client
with that option enabled, the Client
will shutdown on drop.
What do you think?
from nostr.
That sounds good
from nostr.
Done
So, init the Client in this way:
// ...
let opts = Options::new().shutdown_on_drop(true);
let client = Client::with_opts(&keys, opts);
// ...
from nostr.
Related Issues (20)
- `relay.get_events_of` ignores timeout parameter HOT 3
- [Kotlin nostr] Unexpected failure when calling `RelayMessage.fromJson`
- [Kotlin nostr] Implement equals on `PublicKey` and `EventId` HOT 4
- [Kotlin nostr] Include proguard rules HOT 2
- [Kotlin nostr] Default parameters for `Nip19Profile` and `Nip19Event`
- Migrate kotlin packages to `org.rust-nostr`
- sdk not as smart as web browser for binary vs json HOT 2
- [Kotlin nostr] De-/Serialization of `author` in Nip19Event does not work HOT 2
- rust.nostr.protocol.NostrException$Generic: Raw event: Tag: Impossible to find tag kind HOT 4
- Document client addRelay vs connectRelay HOT 1
- Typo "sepcified" -> "specified"
- database: add `author` indexes
- Add method to `EventBuilder` for adding custom tags
- Multiple subscriptions on same event will not be notified HOT 2
- Pool must not assume that REQs are to be sent to all relays HOT 2
- Add `ClientNotification` enum
- sdk: auto authentication to relays for `Client` (NIP42)
- Expose `NostrConnectRemoteSigner` to bindings
- Kind 3 Responses are Too Large HOT 2
- Improve relay limits
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nostr.