profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/bikeshedder/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

bikeshedder/deadpool 422

Dead simple pool implementation for rust with async-await

bikeshedder/deadqueue 20

Dead simple queue implementation for rust with async-await

bikeshedder/futures-test-abort 5

Rust crate for testing the robustness of async libraries when futures are aborted

bikeshedder/django-composite-field 4

This is an implementation of a CompositeField for Django. Composite fields can be used to group fields together and reuse their definitions.

bikeshedder/dbmigrate 1

PostgreSQL/SQLite/MySQL migration tool in rust

bikeshedder/jquery-jsonrpc 1

JSON RPC 2.0 client for jQuery 1.4, 1.5, and 1.6

bikeshedder/jquery-ui 1

The official jQuery user interface library.

bikeshedder/actix-examples 0

Actix web examples

bikeshedder/advent-of-code 0

Rust solutions for https://adventofcode.com/

issue closedbikeshedder/deadpool

Async Safety in `deadpool-diesel`

As far as I can tell, the deadpool-diesel crate does nothing to ensure that blocking database I/O executed by Diesel is executed in a non-blocking fashion, i.e, in a separate worker thread:

https://github.com/bikeshedder/deadpool/blob/2c7a0b7aee915e775f8d751e0a73ec884bae6f71/diesel/src/connection.rs#L59-L61

What am I missing?

closed time in 2 days

SergioBenitez

issue commentbikeshedder/deadpool

Async Safety in `deadpool-diesel`

I'm closing this as the next release of deadpool-diesel will be based on SyncWrapper which enforces the use of the interact method just like the deadpool-sqlite crate.

SergioBenitez

comment created time in 2 days

created tagwebwire/webwire-cli

tagv0.1.6

Webwire Command Line Interface

created time in 2 days

push eventwebwire/webwire-cli

Michael P. Jung

commit sha ff7dae07d2461e2e6a3e303ff9269654b55985c8

Add test for extending enums from different namespaces

view details

Michael P. Jung

commit sha f811d20525a08066359e7bb5e7417abcb9c5dca6

Fix enum extends for types in different namespace

view details

Michael P. Jung

commit sha d5184f43b09257ec5b18dd0e2a96dacf946eec98

Release 0.1.6

view details

push time in 2 days

push eventwebwire/webwire-cli

Michael P. Jung

commit sha 1f0aa21912768fa47ee569773fa0131ebfd97d41

Release 0.1.5

view details

push time in 2 days

created tagwebwire/webwire-cli

tagv0.1.5

Webwire Command Line Interface

created time in 2 days

push eventwebwire/webwire-cli

Michael P. Jung

commit sha b5c4372d80102d72045e336818ac78135d9cc91a

Release 0.1.5

view details

push time in 2 days

push eventwebwire/webwire-cli

Michael P. Jung

commit sha 8054c0bf7bf63d8396378451855542b901a9da1d

Update CHANGELOG

view details

push time in 2 days

push eventwebwire/webwire-cli

Michael P. Jung

commit sha 744d0ad8b1f7c17513f5d3028a0866d58436c817

Fix/Implement enum extension

view details

Michael P. Jung

commit sha afaba09b6a3ccb593d71d57d8ef57946e73749eb

Fix typo in comment

view details

Michael P. Jung

commit sha 0dac57fff39ec353d900188055d823545eef2b33

Improve type references in schema

view details

push time in 2 days

created tagwebwire/webwire-cli

tagv0.1.4

Webwire Command Line Interface

created time in 4 days

push eventwebwire/webwire-cli

Michael P. Jung

commit sha 3994450a73e61512bd3829876e96533f0dea4b98

Fix TS generation for Option type

view details

Michael P. Jung

commit sha 43f130c687f45ba63ba1f8941d1f7064bc904a30

Release 0.1.4

view details

push time in 4 days

issue commentbikeshedder/deadpool

Async Safety in `deadpool-diesel`

I just created a new tracking issue for the deadpool-r2d2 implementation: #116

SergioBenitez

comment created time in 5 days

issue openedbikeshedder/deadpool

Add support for r2d2 managers

By wrapping the r2d2 manager interface it should be rather simple to create pools using the existing r2d2 implementations creating access to a huge ecosystem of existing implementations.

This might even render deadpool-diesel and deadpool-sqlite obsolete.

created time in 5 days

issue commentbikeshedder/deadpool

Async Safety in `deadpool-diesel`

I haven't thought about that. That does indeed sound awesome.

The manager of deadpool works slightly different from the r2d2 one, but the differences should be easy to adapt.


I just finished reworking the deadpool-diesel code and using the SyncWrapper the implementation turned out to be tiny. Even the connection wrapper that implements diesel::Connection is no longer needed as the callback provides access to the unwrapped database connection object.

tbh. I'm not a big fan of the ergonomics of that interact/run interface. Error propagation is kinda ugly and it's easy to mess some types up and get compiler errors which are extremely confusing.

I've seen some code using block_in_place to work around such ergonomic issue. It's clever but dangerous at the same time as it creates the illusion that it's fine to call blocking sync code from async code without any worries.

SergioBenitez

comment created time in 5 days

delete branch bikeshedder/deadpool

delete branch : feature/pool-builder

delete time in 5 days

delete branch bikeshedder/deadpool

delete branch : fix/sqlite-connection-drop

delete time in 5 days

delete branch bikeshedder/deadpool

delete branch : feature/object-customizer

delete time in 5 days

push eventbikeshedder/deadpool

Michael P. Jung

commit sha f5067f99fa12817213e7f7e01563e6a259df1d33

Wrap diesel connections in SyncWrapper

view details

Michael P. Jung

commit sha 92e4ceecd6ca364a01a336ad5c44f11ce7e45f7b

Fix clippy warning

view details

Michael P. Jung

commit sha 0771235d53dbfd06111e86d2a2fcc1d9b466af41

Format code using rustfmt

view details

push time in 5 days

push eventbikeshedder/deadpool

Michael P. Jung

commit sha 570538d44ede5c5ea8c661e7d67116ef5d04361d

Remove obsolete SpawnBlockingError::NoRuntime enum variant

view details

Michael P. Jung

commit sha c0f465da52fff1d34a23d5a932144d10c82d8c86

Add pool builder

view details

Michael P. Jung

commit sha 8ba1992d6e53f7a505b426ec7c6f58402744aae2

Add post_create and post_recycle hooks This is related to #108

view details

Michael P. Jung

commit sha beb50fd82b7c3b633d827b2511111683a43779d3

Fix empty match blocks when no runtime feature is enabled

view details

push time in 5 days

PR merged bikeshedder/deadpool

Add pool builder and post_create/post_recycle hooks

This is related to #110

+456 -132

0 comment

34 changed files

bikeshedder

pr closed time in 5 days

issue closedbikeshedder/deadpool

Add PoolBuilder

Right now the PoolConfig mixes user configuration (max_size and timeouts) with configuration specified by the software developer (runtime).

A new PoolBuilder struct helps to distinguish between those very different configurations and allows for future customizations such as adding special hooks to customize objects after they've been created (see #108).

closed time in 5 days

bikeshedder

issue closedbikeshedder/deadpool

Customizing Connections

For some databases, certain configuration parameters must be set per-connection. The canonical example is SQLite with its PRAGMA-based configuration. With respect to deadpool, the ideal place to do this would be immediately before/after a connection is made to be placed in the pool. As far as I can tell, deadpool provides no such hook to accomplish this, short of writing a custom Manager. Is that correct?

For reference, the analog in r2d2 is connection_customizer.

closed time in 5 days

SergioBenitez

push eventbikeshedder/deadpool

Michael P. Jung

commit sha 21961a03d90f3d2ed790d1b7362b94fd7aa00bb0

Run drop of rusqlite::Connection inside spawn_blocking This fixes #114

view details

Michael P. Jung

commit sha be8fcaa220e7a17d924bb9076254aedf44752f1b

Format code and add comment

view details

Michael P. Jung

commit sha 47f1f36f726840f66687ef495c893df2434f9fcd

Add check if mutex is poisoned when dropping connection

view details

Michael P. Jung

commit sha 3925bd69ec05462d9bd53ec3e02dd8e11417ef1c

Implement proper panic handling This fixes #113

view details

Michael P. Jung

commit sha 4d6096eeee9f5c5acc4044a1820e06dcb6303610

Add Runtime::spawn_blocking method This closes #106

view details

Michael P. Jung

commit sha e21e6ba27297d41c10383e88735c46f7d91d26e0

Change spawn_blocking method to support return values

view details

Michael P. Jung

commit sha 0d52354228892e5ac294b919a076a82952e5f027

Add Runtime::spawn_blocking_background method

view details

Michael P. Jung

commit sha 1133284d79290d635e4910f2f4593e10478f6b1f

Implement std::error::Error for SpawnBlockingError

view details

Michael P. Jung

commit sha 1732d389a77032743ed84ef3d9660a51e8a864f6

Add SyncWrapper and support for multiple runtimes

view details

Michael P. Jung

commit sha ccba10cc6ddf61765e41a2b8c2c45cc17f17bb58

Update deadpool-sqlite CHANGELOG

view details

Michael P. Jung

commit sha d7a77de5d6b8be2867a4b9b99b650b3c523859bb

Replace Runtime::None variant by Option<Runtime> The runtime is mandatory for managers and connections that need to run blocking code.

view details

Michael P. Jung

commit sha 070d588f52e73d7b6d0727f7685536380fc8a4d7

Use import instead of fully qualified name

view details

Michael P. Jung

commit sha 394a635e0f4f5223f676a1bad5d4459ff6b63941

Remove obsolete SpawnBlockingError::NoRuntime enum variant

view details

Michael P. Jung

commit sha e151289e41be0f27d8f0ec9972002f528e0dab92

Add pool builder

view details

Michael P. Jung

commit sha 506989c04c0e2e4428381972c3a70bf4a0bb876e

Add post_create and post_recycle hooks This is related to #108

view details

Michael P. Jung

commit sha bfa966183dfd6ff683a4c25a9fbabba224f904c3

Fix empty match blocks when no runtime feature is enabled

view details

push time in 5 days

push eventbikeshedder/deadpool

Michael P. Jung

commit sha 070d588f52e73d7b6d0727f7685536380fc8a4d7

Use import instead of fully qualified name

view details

push time in 5 days

push eventbikeshedder/deadpool

Michael P. Jung

commit sha e21e6ba27297d41c10383e88735c46f7d91d26e0

Change spawn_blocking method to support return values

view details

Michael P. Jung

commit sha 0d52354228892e5ac294b919a076a82952e5f027

Add Runtime::spawn_blocking_background method

view details

Michael P. Jung

commit sha 1133284d79290d635e4910f2f4593e10478f6b1f

Implement std::error::Error for SpawnBlockingError

view details

Michael P. Jung

commit sha 1732d389a77032743ed84ef3d9660a51e8a864f6

Add SyncWrapper and support for multiple runtimes

view details

Michael P. Jung

commit sha ccba10cc6ddf61765e41a2b8c2c45cc17f17bb58

Update deadpool-sqlite CHANGELOG

view details

Michael P. Jung

commit sha d7a77de5d6b8be2867a4b9b99b650b3c523859bb

Replace Runtime::None variant by Option<Runtime> The runtime is mandatory for managers and connections that need to run blocking code.

view details

push time in 5 days

Pull request review commentbikeshedder/deadpool

Run drop of rusqlite::Connection inside spawn_blocking and fix panic handling

 impl ConnectionWrapper {             .await             .unwrap()?;         Ok(ConnectionWrapper {-            conn: Arc::new(Mutex::new(conn)),+            conn: Arc::new(Mutex::new(Some(conn))),         })     }     /// Interact with the underlying SQLite connection. This function     /// expects a closure that takes the connection as parameter. The     /// closure is executed in a separate thread so that the async runtime     /// is not blocked.-    pub async fn interact<F, R>(&self, f: F) -> R+    pub async fn interact<F, R>(&self, f: F) -> Result<R, InteractError>     where-        F: FnOnce(&rusqlite::Connection) -> R + Send + 'static,+        F: FnOnce(&rusqlite::Connection) -> Result<R, rusqlite::Error> + Send + 'static,         R: Send + 'static,     {-        let conn = self.conn.clone();-        tokio::task::spawn_blocking(move || f(&*conn.lock().unwrap()))-            .await-            .unwrap()+        let arc = self.conn.clone();+        tokio::task::spawn_blocking(move || {+            let guard = arc.lock().unwrap();+            let conn = guard.as_ref().unwrap();+            f(&conn)+        })+        .await+        .map_err(|e| {+            if e.is_panic() {+                InteractError::Panic(e.into_panic())+            } else if e.is_cancelled() {+                InteractError::Aborted+            } else {+                unreachable!();+            }+        })?+        .map_err(InteractError::Rusqlite)+    }+}++impl Drop for ConnectionWrapper {+    fn drop(&mut self) {+        let arc = self.conn.clone();+        // Drop the `rusqlite::Connection` inside a `spawn_blocking`+        // as the `drop` function of it can block.+        tokio::task::spawn_blocking(move || match arc.lock() {+            Ok(mut guard) => guard.take(),+            Err(e) => e.into_inner().take(),+        });

Right. drop(...) makes it absolutely clear. I'm currently rewriting this as a generic SyncWrapper which can be used for deadpool-diesel as well.

bikeshedder

comment created time in 6 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentbikeshedder/deadpool

Run drop of rusqlite::Connection inside spawn_blocking and fix panic handling

 impl ConnectionWrapper {             .await             .unwrap()?;         Ok(ConnectionWrapper {-            conn: Arc::new(Mutex::new(conn)),+            conn: Arc::new(Mutex::new(Some(conn))),         })     }     /// Interact with the underlying SQLite connection. This function     /// expects a closure that takes the connection as parameter. The     /// closure is executed in a separate thread so that the async runtime     /// is not blocked.-    pub async fn interact<F, R>(&self, f: F) -> R+    pub async fn interact<F, R>(&self, f: F) -> Result<R, InteractError>     where-        F: FnOnce(&rusqlite::Connection) -> R + Send + 'static,+        F: FnOnce(&rusqlite::Connection) -> Result<R, rusqlite::Error> + Send + 'static,         R: Send + 'static,     {-        let conn = self.conn.clone();-        tokio::task::spawn_blocking(move || f(&*conn.lock().unwrap()))-            .await-            .unwrap()+        let arc = self.conn.clone();+        tokio::task::spawn_blocking(move || {+            let guard = arc.lock().unwrap();+            let conn = guard.as_ref().unwrap();+            f(&conn)+        })+        .await+        .map_err(|e| {+            if e.is_panic() {+                InteractError::Panic(e.into_panic())+            } else if e.is_cancelled() {+                InteractError::Aborted+            } else {+                unreachable!();+            }

I added that last else block if there is ever the chance that a third option is added.

But then... this is unlikely ... yet it would generate a meaningful panic. :thinking:

bikeshedder

comment created time in 6 days

issue closedbikeshedder/deadpool

Add Runtime::spawn_blocking

This is needed by deadpool-diesel in order to create and recycle connections.

Right now deadpool-diesel uses tokio::task::spawn_blocking directly which is not optimal and breaks when disabling the rt_tokio_1 feature.

closed time in 6 days

bikeshedder