-
Notifications
You must be signed in to change notification settings - Fork 190
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
kie-issues#1694: Apache KIE Extended Services extension issues #2802
base: main
Are you sure you want to change the base?
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.
@yesamer Thanks for your PR! I've made some comments inline.
export const enableAutoRunID = "extendedServices.enableAutorun"; | ||
export const connectionHeartbeatIntervalinSecsID = "extendedServices.connectionHeartbeatIntervalinSecs"; | ||
export const extendedServicesURLID = "extendedServices.extendedServicesURL"; | ||
const defaultExtendedServicesURL = "http://localhost:21345"; |
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.
We should use the env
value instead of hardcoding. To do so, take a look into the build/defaultEnvJson.ts
file in some packages (e.g. online-editor
).
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.
@ljmotta It's a good point. I would like to retrieve that default value directly from the configuration here https://github.com/apache/incubator-kie-tools/pull/2802/files#diff-153d43651b25ee3120020fae349c9e8ed99ccf90aa15995784702244decf9499R91 to avoid duplication and a single place for that property value, do you think is a valid alternative should I consider?
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.
yes, it is important to have an option to configure the url of extended services, users report issues about it #2759
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.
@ljmotta In the examples I checked, the env variables are accessed using the useEnv() hook, but in this case, we are not managing a React app. How can I access to env variable from "plain" typescript?
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.
@yesamer That's true. the defaultEnvJson
is used with the webpack transform + fetch
, which isn't the case here. Now, you could use the webpack's EnvironmentPlugin
to set env variables. The online-editor
uses this approach to set some values inside the codebase. Take a look into the online-editor/webpack.config.ts
, and search for EnvironmentPlugin
. The WEBPACK_REPLACE__*
values are the ones used in the codebase.
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.
@ljmotta It should be done, there are two points to discuss:
- I added EnvironmentPlugin in both extension-main and extension-browser. There's a way to define that once?
- Currently, the host and the post are parametrized, In my opinion, it would be better to have the entire URL as a parameter. E.g. http protocol is hardcoded, what if the user provides its own instance using https?
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.
- If you need to use in both, you can set the env variables in the
commonConfig
variable. - Good point. I'm not familiar on how the user set/use the Extended Services in the VS Code extension. Is it a embeded Extended Services or the user need to manually start the server? For the
extended-services-java
it will always usehttp
. If the user wants to deploy it, the user will need to make the necessary adjustments to make it available throughhttps
.
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.
- Do you have an example for that? I mean, I added the plugin entry for both
web
andnode
https://github.com/apache/incubator-kie-tools/pull/2802/files#diff-1768335dedd5cfa5e1b3830bb3b6c504f1d316dea21de55738df74f7f19c27a5R52
To create a single entry for the plugin, whichtarget
andentry
should I use? - You're right, considering extended-services-java always uses
http
, we are safe here :)
const value = vscode.workspace.getConfiguration().get(property) as T; | ||
if (!value) { | ||
console.warn("Property: " + property + " is missing, using the default: " + defaultValue); | ||
} | ||
return value || defaultValue; | ||
}; |
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.
I'm not sure if I followed. T
can be a boolean
, number
or string
. If is a boolean
it will always be true
, as it is the default value. For number
, can't be 0
, and string
can't be ""
? Or value
can't be undefined
? The (!value)
can be tricky, please, make it explicity.
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.
T can be a boolean, number or string. If is a boolean it will always be true, as it is the default value. For number, can't be 0, and string can't be ""
So, if the user explicitly removes the property the default value is always returned?
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.
@yesamer I just considered the calls to this method. We have just 3 on this file, each one of them with T equals to boolean
, number
or string
. The if
will be true
for the cases I listed, and we will have the log. Additionally, the return will always go to the default value for the same cases:
> "" || "my_default_value"
'my_default_value'
> 0 || 25
25
> false || true
true
If the value
(has the type T
due your casting) can have a different type, please make it explicity. Something like: T | null
or T | undefined
.
packages/extended-services-vscode-extension/src/requests/ValidationRequests.ts
Outdated
Show resolved
Hide resolved
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.
Thank you for the PR. I am happy we improve this extension.
01
Sometimes we use extended service
(singletone) and sometimes we use extended services
(plural).
02
The PR description says we never stop the extended services. Should then extension-browser.ts
contain const stopExtendedServicesCommandUID: string = "extended-services-vscode-extension.stopExtendedServices";
and related code? Or do we keep the option to manually stop the extended services?
No manual check done, waiting until code changes are finished.
export const enableAutoRunID = "extendedServices.enableAutorun"; | ||
export const connectionHeartbeatIntervalinSecsID = "extendedServices.connectionHeartbeatIntervalinSecs"; | ||
export const extendedServicesURLID = "extendedServices.extendedServicesURL"; | ||
const defaultExtendedServicesURL = "http://localhost:21345"; |
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.
yes, it is important to have an option to configure the url of extended services, users report issues about it #2759
packages/extended-services-vscode-extension/src/configurations/Configuration.ts
Outdated
Show resolved
Hide resolved
packages/extended-services-vscode-extension/src/extension/extension-browser.ts
Outdated
Show resolved
Hide resolved
packages/extended-services-vscode-extension/src/extension/extension-main.ts
Outdated
Show resolved
Hide resolved
# Conflicts: # packages/extended-services-vscode-extension/src/configurations/Configuration.ts
@jomarko 02 |
Fixes apache/incubator-kie-issues#1684
In this PR:
The main issue is the "ambitious" management of the Extended Service Quarkus App lifecycle.
The original idea was to run the Quarkus application just after a DMN / BPMN file is opened in the editor and close it when all files are closed. Unfortunately, that implementation didn't consider the following scenarios:
For that reason, I simplified the logic: the Extended Service Quarkus App is started when a DMN / BPMN file is opened for the first time and never stopped. The original idea was indeed better from a performance and resource consumption point of view, but it requires a more complex implementation.
extendedServices.connectionHeartbeatIntervalinSecs
default value changed from 1 to 10. Having a heartbeat occurring every second contributed to the reported issue