Git Product home page Git Product logo

Comments (7)

gftea avatar gftea commented on May 24, 2024

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.

Cryptex-github avatar Cryptex-github commented on May 24, 2024

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

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.

gftea avatar gftea commented on May 24, 2024

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.

Cryptex-github avatar Cryptex-github commented on May 24, 2024

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

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.

gftea avatar gftea commented on May 24, 2024

is_open will get automatically set to false when the connection closed, even if no callback is registered?

That’s right

from amqprs.

gftea avatar gftea commented on May 24, 2024

if no more issue with it, I would close it in the near future

from amqprs.

Cryptex-github avatar Cryptex-github commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.