google-cloud-rust icon indicating copy to clipboard operation
google-cloud-rust copied to clipboard

spanner: allow moving sessions between clients

Open danielnorberg opened this issue 3 months ago • 1 comments

We spawn subprocesses that need to perform latency critical spanner queries immediately on startup. One of the impediments to this setup is that creating a spanner session can be a slow operation.

Would it be possible to allow moving sessions from one client to another? Then the parent process could prepare sessions ahead of time and pass them to the subprocess on startup. I.e., take Session protos holding the session name from the parent process spanner client then serialize and pass them to the subprocess which would then deserialize and pass them in when creating a new spanner client.

danielnorberg avatar Sep 29 '25 06:09 danielnorberg

Since the Spanner session itself becomes a simple struct, you can perform any operation using that string. However, the requested behavior goes beyond the scope of the library, so you'll need to manually copy and manage it yourself.

https://github.com/yoshidan/google-cloud-rust/blob/4637c081f43a455195ffd52703b7aaf99c198cbd/spanner/src/session.rs#L26C18-L26C25

yoshidan avatar Nov 09 '25 09:11 yoshidan