testcontainers-rs icon indicating copy to clipboard operation
testcontainers-rs copied to clipboard

Remove Container lifetime

Open ufoscout opened this issue 2 years ago • 1 comments

The lifetime on the Container struct is useless because the container owns the Cli, so Rust guarantees that the client cannot be dropped while the container is in scope. This makes also the Container Send and Sync which can be useful in some complex test scenarios

ufoscout avatar Oct 31 '23 10:10 ufoscout

I agree that this lifetime should go away. The discussion around that is in https://github.com/testcontainers/testcontainers-rs/issues/386.

I don't want to just remove it without the requirements around creation and removal of networks being properly addressed.

thomaseizinger avatar Nov 13 '23 01:11 thomaseizinger

This PR hides the fact of dependency between Client and Container. Any networks created for container are being removed only on drop of client.

I also agree that we need to rework this, but not this way.

I'm going to close the PR, because another reason is that we going to deprecate Cli client and probably re-work HTTP one.

Don't hesitate to continue discussion in the related issue. We will figure out optimal way to make it reliable. Thank you!

DDtKey avatar Apr 06 '24 17:04 DDtKey