-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make TspClient reuseable interface #83
Make TspClient reuseable interface #83
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this enabling contribution yes. So these would be my few (minor) comments.
Now this PR would require extensions [1,2,3] adaptations, so they build and work upon using it. Would you be able to contribute companion PRs for those alongside this one, accordingly? The goal would also be to further test this very PR that way, making sure that it works in [1,2,3]'s own contexts in turn. The original goal of supporting [4] remains alongside.
The concern of potentially breaking other (unforeseen) client integrations remains, though. Even if likely only a matter of renaming the type; as this has been a published API for a while now. Is there something we could do for this, say, scaffolding a backward-compatible (yet lightweight) structure first? -Which would come with a deprecation plan or so.
[1] https://github.com/eclipse-cdt-cloud/theia-trace-extension
[2] https://github.com/eclipse-cdt-cloud/vscode-trace-extension
[3] https://github.com/eclipse-cdt-cloud/vscode-trace-server
[4] eclipse-cdt-cloud/theia-trace-extension#990
@marco-miller I updated the PR according to your two feedback comments. I will also provide PRs in the coming days for the dependedent projects. Regarding the breaking of other dependent projects: I think the main problem tha we have is that the new interface has the same name as the old constructor. Hence exporting a constructor for TspClient will not work if i am not mistaken. Do you have another idea on how to achieve this? BTW, i feel like it makes sense to get this PR merge ready, before updating the PRs in the dependent projects in case we change something here. |
Thanks again for all this.
We could consider keeping the legacy constructor (class) as is. While making it extend a new, differently named interface, behind the scenes -so to speak. Then add the new constructable sibling alongside that legacy one (extending that interface too). Existing clients wouldn't be broken, yet could eventually choose to switch to the new implementation.
Agree; makes sense to me too. |
Would we really provide a "separate implementation" for the old constructor? Wouldnt it be sufficient to do something like: export class TspClient extends HttpTspClient {} This way we do not need to provide another implementation or delegate and existings clients will not break. WDYT? Do you have any suggestions for the name of the interface? Are we planning to rename it to TspClient once we deprecate the constructor or should the name be permanent? |
Agree. I'd in fact be for the less breaking and most stable (yet still fitting) solution possible here. So, as far as
How about |
No use creating a child class when all you want is an alias: /** @deprecated use {@link HttpTspClient} directly instead. */
export const TspClient = HttpTspClient; |
If I may, I'd throw |
Finding good names are often tricky. With this change |
"TspClient" as interface name and "HttpTspClient implements TspClient" would make sense. For backwards-compatibility reasons and to avoid having to update each user of TspClient (theia-trace-extension and vscode-trace-extension) right away we don't have a choice to find a new name for the interface. Maybe using the prefix I is not such a bad idea in this case. I have seen that being done in the actual VsCode Typescript code base. So we wouldn't be the only ones :-) WDYT? |
Adding to @bhufmann's latest proposal (which I'd foster, along with @paul-marechal's |
Thanks a lot for the suggestions! I now went with I tried using a simple alias, which worked for the constructors, but not for the types, due to:
So instead i went for the I also tested it with [2] and [3] and there seem to be no breakages. I am currently working on extending eclipse-cdt-cloud/theia-trace-extension#990 to work with these changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the rework. At this stage, most of the fix-up commits could be squashed, as they're review-based steps more than commitable increments. The resulting commit message(s) can be confirmed alongside.
d16ddd1
to
3602d61
Compare
The new interface is called `ITspClient`. `ITspClient` can be used for typing and other implementations. The existing functionality was moved to the `HttpTspClient`. To not break the existing behavior `TspClient` is still exported as an alias for the `HttpTspClient`, but is being deprecated. This way adopters should be notified to migrate to `HttpTspClient`. This makes the package more flexible as different implementations can be provided, e.g. a proxy client in a Theia frontend. Part of eclipse-cdt-cloud/theia-trace-extension#976 Contributed on behalf of STMicroelectronics
3602d61
to
95b2547
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending @bhufmann's 2nd review; thanks.
- I
yarn
-linked this client version into the aforementioned[1,2,3]
and was able to build and run tests where available. - I opened the files using
TspClient
and didn't notice new/related warnings in VSC. - The
HttpTspClient
implementation looks identical to the legacyTspClient
one to me locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me. Works fine with theia-trace-extension
and vscode-trace-extension
.
Thanks for the contribution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice modularity!
To consume the new types introduced with eclipse-cdt-cloud/tsp-typescript-client#83. Invoke the yarn clean script before running the prepare script. Make sure all imports are from `lib` instead of `src`. Contributed on behalf of STMicroelectronics
The
TspClient
is now an interface that can be used for other implementations. The existing functionality was moved to theDefaultTspClient
. This means adopters now need to initialize theDefaultTspClient
type instead ofTspClient
to get the default behavior. However this makes the package more flexible as different implementations can be provided, e.g. a proxy client in a Theia frontend.Part of eclipse-cdt-cloud/theia-trace-extension#976
Contributed on behalf of STMicroelectronics
Note: Once this is merged i can update this PR to consume the changes.