Avoid double Client SafeHandle implementation#602
Avoid double Client SafeHandle implementation#602jmaeagle99 wants to merge 1 commit intotemporalio:mainfrom
Conversation
8fc0a13 to
7da468b
Compare
Sushisource
left a comment
There was a problem hiding this comment.
Guess this one fell off the radar somehow huh
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Possibly. Their methods would have to go somewhere (not the Safe*Handle, because that's the whole point of the separation).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
What was changed
Changed the bridge client to no longer implement
SafeHandleand to only implementIDisposable. This required that more information is pass via a newIBridgeClientProviderInternalinterface that exposes theSafeClientHandleand theRuntimeinstances from theTemporalConnection.Why?
Avoid the double creation of
SafeHandleimplementations for bridge clients.Checklist