You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, it is not possible to confer WithWatch on an existing client: one can only obtain a client.WithWatch via a constructor:
cWithWatch, err:=client.NewWithWatch(cfg, opts)
The resulting client is "frozen" -- i.e. can't be subjected to decorators like WithFieldOwner -- because those wrappers return a client.Client, which can't Watch()!
It would be great to have a decorator function to allow an existing client to grow WithWatch functionality:
It would be better to call the wrapper WithWatch, but that name is already taken by the interface. Sad face.
I can't think of a way to get around this client being "the end of the line". It can't be further wrapped, unless the wrapper is WithWatch-specific. Sad face.
It would be great if you could do this to any client.Client; but as written today that would be hard because the Watch() implementation relies on internals of the specific client (lowercase) implementation in the library. Sad face.
See #2929 where I prototyped an imperfect version of the solution that suffers from all of the above issues.
The text was updated successfully, but these errors were encountered:
To expand on what I was thinking, I thought we might be able to have some sort of wrapper type for the various options that takes a client.Client or client.WithWatch through generics and returns whatever it has gotten. The main drawback is that the return will always be assertable to WithWatch even if it it isn't.
Note that this plays into #2888, we should probably solve the two problems together
In some cases, one can wrap already-extant
client.Client
s to confer extra functionality. For example:However, it is not possible to confer
WithWatch
on an existing client: one can only obtain aclient.WithWatch
via a constructor:The resulting client is "frozen" -- i.e. can't be subjected to decorators like
WithFieldOwner
-- because those wrappers return aclient.Client
, which can'tWatch()
!It would be great to have a decorator function to allow an existing client to grow
WithWatch
functionality:Notes:
WithWatch
, but that name is already taken by the interface. Sad face.WithWatch
-specific. Sad face.client.Client
; but as written today that would be hard because theWatch()
implementation relies on internals of the specificclient
(lowercase) implementation in the library. Sad face.See #2929 where I prototyped an imperfect version of the solution that suffers from all of the above issues.
The text was updated successfully, but these errors were encountered: