Comments (7)
Hi, manually set is_open
will alllow user to mutate the internal state of connection which break the the contract of open
and close
, I would perfer not to go this way.
I am not familar with deadpool
, can you elaborate further why &self
is necessary? current API will avoid user to use the connection unexpectedly after close the connection.
Can the new type pattern works for you? Usually we can implement new type in order to suite the contract required by other libraries
from amqprs.
Hi, manually set
is_open
will alllow user to mutate the internal state of connection which break the the contract ofopen
andclose
, I would perfer not to go this way.I am not familar with
deadpool
, can you elaborate further why&self
is necessary? current API will avoid user to use the connection unexpectedly after close the connection. Can the new type pattern works for you? Usually we can implement new type in order to suite the contract required by other libraries
So deadpool is a connection pool, it allows user to implement their own pool with whatever library if they implement the Manager
trait for their own Manager, the trait signature is as below:
#[async_trait]
impl managed::Manager for Manager {
type Type = Connection;
type Error = amqprs::error::Error;
async fn create(&self) -> Result<Self::Type, Self::Error> {
Ok(Connection::open(&self.con_args).await?)
}
async fn recycle(&self, conn: &mut Self::Type) -> RecycleResult<Self::Error> {
todo!()
}
Now the only method we are concerned here is recycle
, which only provides a &mut Self::Type, while I am not entirely sure why, but is likely due to how deadpool holds each objects.
Can the new type pattern works for you? Usually we can implement new type in order to suite the contract required by other libraries
I am not entirely sure about what that means, can you please further elaborate?
from amqprs.
As I understand, you should not call close
in recycle
because it must be alive and be reused in a pool.
you can read about new type pattern, see explanation
from amqprs.
As I understand, you should not call
close
inrecycle
because it must be alive and be reused in a pool.you can read about new type pattern, see explanation
Whoops, yes you are right I misunderstood what it means by recycle
(should have looked at examples), based on the assumption that is_open will get automatically set to false when the connection closed, even if no callback is registered?
from amqprs.
is_open will get automatically set to false when the connection closed, even if no callback is registered?
Thatβs right
from amqprs.
if no more issue with it, I would close it in the near future
from amqprs.
if no more issue with it, I would close it in the near future
Yes there is no more issue related to this topic, feel free to close it if you want to.
from amqprs.
Related Issues (20)
- FieldTable does not accept integer type HOT 3
- Implementing Prefetch for a given Queue using AsyncConsumer HOT 2
- Feature request: Support for external authentication mechanism HOT 3
- ChannelCallback::cancel() not called when server delete queue HOT 3
- Support `OpenConnectionArguments::from_url`? HOT 2
- Parsing Headers into Strings?
- Parsing Headers into Strings? HOT 3
- "channel concurrency" inconsistency between documentation & implementation HOT 1
- improvement: amqp_serde design and APIs
- Error running the publisher subsriber example. HOT 4
- Consumer immediately gets closed HOT 2
- BasicProperties: expose delivery mode (persistent vs. transient) as a boolean or enum HOT 3
- "Alternative default: queue declaration arguments HOT 1
- BasicPublishArguments: deprecate the immediate field HOT 2
- BasicConsumeArguments: rename no_ack since it is confusing HOT 3
- Address (most) clippy warnings HOT 3
- ConsumerMessage.delivery and .basic_properties should not be options HOT 2
- ExchangeDeclareArguments: exchange type is inherently an enum HOT 3
- FieldTable needs a convenience method for instantiation from a map HOT 4
- Best practices for opening channel, and prevent it from being dropped. HOT 4
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 amqprs.