Comments (6)
If this is just additional functionality then I've no concerns. I misunderstood and thought the proposal was to change the current behavior which could cause some problems.
from openhab-core.
I don't have that power. A maintainer needs to come along and review the PR.
from openhab-core.
I commented on the PR because I didn't see this issue at first. Here is a better place to have the discussion.
This might be a breaking change. Right now when one rule calls another rule, the call blocks until the called rule returns.
For example:
console.info('Calling rule');
rules.runRule('longrunning', {}, true);
console.info('Rule returned');
with longrunning
console.info('Long running rule called');
Java.type('java.lang.Thread').sleep(5000);
console.info('Sleep done');
produces the following output:
2024-01-29 11:06:35.142 [INFO ] [nhab.automation.script.ui.scratchpad] - Calling rule
2024-01-29 11:06:35.978 [INFO ] [hab.automation.script.ui.longrunning] - Long running rule called
2024-01-29 11:06:40.997 [INFO ] [hab.automation.script.ui.longrunning] - Sleep done
2024-01-29 11:06:40.997 [INFO ] [nhab.automation.script.ui.scratchpad] - Rule returned
If I understand this proposal that behavior would change and the call to runRule
would immediately return. This could break some end user's rules if they depend on this blocking behavior.
from openhab-core.
Hello)
It’s not a change, but an addition.
runNow
methods of the org.openhab.core.automation.RuleManager
are still in place and work the same way as before.
It’s up to automation scripting addons maintainers/designers to decide how to expose new calling methods (instead or besides the existing) and whether to expose them at all.
My aim is to expose some API for running rules to the Groovy scripting without the need to resort to getting services from the OSGi and without errors on parallel execution.
I thought this PR would be a good first step.
from openhab-core.
Talking about code snippets.
As I’ve said earlier, it’s up to maintainers/designers of an addon to decide how to expose new API.
One way to solve an issue with immediate return and reordering would be to wait for a Future
from one of the newly proposed scheduleRun
methods to complete.
Awaiting can be done inside the addon and not be exposed to the addon user/script writer.
Another way can be to return Future/Promise from the runScript
(or any new additional method/function to expose new calling method) and let user to decide what to do.
As far as I understand, snippets are JS scripting examples. Unfortunately, I’m not familiar with JS scripting addon internals and not confident that there are no pitfalls with proposed strategies to mitigate early return from scheduleRun
.
If you have a proposal on how to make an API more convenient or useful - I’m all ears.
from openhab-core.
In case there's no more objections, can someone approve pull request?
from openhab-core.
Related Issues (20)
- REST endpoint to get Jetty‘s TLS certificate HOT 1
- ECMAScript: Quantity can't be multiplied with negative value HOT 2
- Binding ID in JarFileAddonService vs. KarafAddonService HOT 4
- New version 3.0.0 of JUPnP library is breaking at least Sonos binding when several interfaces are up HOT 61
- sendNotification not working inside DSL script in a rule HOT 1
- Units of Measurement (UoM) missing: g/m² and Wh/m² (for solar panels monitoring) HOT 1
- Cannot retrieve config description with REST API HOT 3
- Inconsistent karaf output for `addons services`
- REST endpoint GET `/rest/items/<itemname>` broken HOT 4
- [rfc] UoM shall I create a new unit(s) for humidity?? HOT 7
- Dimension in `thing-description-1.0.0.xsd` HOT 2
- Resolver error introduced with Karaf upgrade to 4.4.5 HOT 12
- Wrong usage of `SameSite` cookie param in `TokenResource` HOT 5
- QuantityType<Time> incorrectly formats durations HOT 14
- QuantityType<Dimensionless> with unit one wrong update to item with different unit set HOT 2
- CI build throws "java.util.zip.ZipException: zip END header not found" HOT 7
- [sitemap] Add labelcolor and visibility to a single button of a Buttongrid HOT 27
- Java 21 deserialization of DateTime HOT 10
- Report ruleUID when Script Condition doesn't return a boolean
- [marketplace] Supported Bundle Versions No Longer Processed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openhab-core.