Skip to content

Add the ability for manual invalidation of requests, preventi…#28

Closed
arb000r wants to merge 2 commits into
HaveFunTrading:mainfrom
arb000r:feat/user-initiated-invalidation
Closed

Add the ability for manual invalidation of requests, preventi…#28
arb000r wants to merge 2 commits into
HaveFunTrading:mainfrom
arb000r:feat/user-initiated-invalidation

Conversation

@arb000r

@arb000r arb000r commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Hello,

I would like to propose a feature to allow manual invalidation of requests.
Currently the pool (and any custom implementations) can only rely on disconnected as the primary flag for overseeing that a Connection is not pushed back into the pool. Updating it so that the disconnected flag could be updated did not seem to be the correct path, as it the flag would be responsible for two meanings.

I introduced a new flag called invalidated which can be marked by the request, which results in the underlying Connection not making it back to the pool.

arb000r added 2 commits April 20, 2026 15:05
…ng underlying connection from being reused in custom pool implementations.
@HaveFunTrading

Copy link
Copy Markdown
Owner

hi @arb000r - could you provide some use cases for the above? if we want more control over when a connection is dropped when returned to the pool I would try to make the contract stronger/better defined rather than relying on certain field(s).

@arb000r

arb000r commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

Heya,

The example I was trying to make it fit was for expiring requests.

  1. Create request with a defined deadline
  2. Request is polled through a wrapper fn which checks above deadline. If deadline has passed. Return Err.
  3. Even though from a client implementation the deadline is passed, that connection may eventually have the response arrive. If the connection is returned to the pool and used for another request, the previous response will still be there.

The ability to invalidate a certain connection arbitrarily would be useful for custom pool implementations.

@HaveFunTrading

Copy link
Copy Markdown
Owner

sorry for the late reply @arb000r

I have reviewed this and added a way to invalidate the HttpRequest

    /// Immediately terminate and consume this request.
    ///
    /// The request's connection is dropped instead of returned to the pool. Use this when the request
    /// can no longer complete or its connection may not be safe to reuse, such as after a timeout.
    pub fn invalidate(mut self) {
        self.conn.take();
    }

it will be released in 0.0.79

in the meantime I will close your PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants