Trying to update diesel_logger to work with diesel_async, trouble with lifetime issue #98
Replies: 1 comment
-
The error message is not that surprising. In this code block: async move {
let start_time = Instant::now();
let result = self.connection.execute_returning_count(source).await;
let duration = start_time.elapsed();
log_query(&query_sql, duration);
result
}.boxed() you move Now the question is how to fix that. Due to time constraints I cannot do experimentation there myself but the first thing I would try is to change the As semi releated side note:
That code will not do what you expect it to do. It will only measure the time that's required to construct the corresponding future, not the execution time of the query. |
Beta Was this translation helpful? Give feedback.
-
I am attempting to update
diesel_logger
(https://github.com/shssoichiro/diesel-logger) to work withdiesel_aync
and have hit a final roadblock I can't solve with a lifetime issue around anAsyncConnection
implementation ofexecute_returning_count
the specific code with the lifetime issue is:With the error being:
Any help/advice with resolving this lifetime would be great!
I have got it working using a concret implementatation with
AsyncPgConnection
rather than generic but was hoping to make it generic if possible. If it is not possible to resolve this lifetime I guess I could just provide conrete implementations for PostgreSQL and MySQL.The whole implementation is:
Full code can be accessed from: https://github.com/Zero41/diesel-logger/tree/add-support-for-diesel-async
Beta Was this translation helpful? Give feedback.
All reactions