Skip to content

Avoid double Client SafeHandle implementation#602

Open
jmaeagle99 wants to merge 1 commit intotemporalio:mainfrom
jmaeagle99:client-safe-handle
Open

Avoid double Client SafeHandle implementation#602
jmaeagle99 wants to merge 1 commit intotemporalio:mainfrom
jmaeagle99:client-safe-handle

Conversation

@jmaeagle99
Copy link
Contributor

What was changed

Changed the bridge client to no longer implement SafeHandle and to only implement IDisposable. This required that more information is pass via a new IBridgeClientProviderInternal interface that exposes the SafeClientHandle and the Runtime instances from the TemporalConnection.

Why?

Avoid the double creation of SafeHandle implementations for bridge clients.

Checklist

  1. Closes Refactor Bridge.Client to be IDisposable instead of a SafeHandle #587
  2. How was this tested: Unit tests
  3. Any docs updates needed? No

@jmaeagle99 jmaeagle99 marked this pull request as ready for review February 17, 2026 22:20
@jmaeagle99 jmaeagle99 requested a review from a team as a code owner February 17, 2026 22:20
Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess this one fell off the radar somehow huh

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just remove this class and only have SafeClientHandle? Same for the Worker one. I can't really see a benefit of having this thin layer on top.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly. Their methods would have to go somewhere (not the Safe*Handle, because that's the whole point of the separation).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't the methods be on the safe handle? Is the separation beneficial? It's not truly wrapping it if you're still accessing and using the safe handle elsewhere.

Copy link
Contributor

@cretz cretz Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit confused on the need for this and IBridgeClientProvider. Is this duplicating that one's purpose? What was wrong with what was there and the cast?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I am breaking apart the safe handles from their wrapper classes, I'm also passing around only the safe handle and not the wrapper classes anymore.

So if you look at the bridge Worker constructor, I now require passing the SafeClientHandle and the Runtime instead of the Client instance. This requires that I'm able to get the Runtime from the bridge provider somehow; but now that Client doesn't implement SafeHandle anymore, I can't just cast IBridgeClientProvider.BridgeClient to Client.

I have to either update that public interface (which might be okay, if that's not meant to be implemented by anyone outside of the SDK) or introduce a new internal interface that we can put whatever we want on it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not pass around the wrapper? The reason we made ITemporalConnection be an IBridgeClientProvider and made that public is so if someone wrapped/implemented the connection, they could return the underlying one's BridgeClient. And that can still be used for creating workers. It was all public by intention. But at first glance, it looks like this is a breaking change because now a user's IWorkerClient that might have returned their ITemporalConnection (which implements IBridgeClientProvider by maybe delegating to the underlying one) that used to work for creating a worker can no longer work. I admit it is a bit of a contrived use case, but we did make it public on purpose.

I have to either update that public interface

Why? The worker needs the SafeHandle, why can't it continue to provide it? Isn't that what the internal one is doing, just providing the safe handle? Also, arguably the runtime should be on the safe handle for this use case.

Maybe I don't quite get the value of the separation/wrapper vs just having one safe client handle that does everything a bridge client needs to do.

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.

Refactor Bridge.Client to be IDisposable instead of a SafeHandle

3 participants