-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement override triggers. #825
Conversation
…30.triggers-class
…gers.40.deep-sleep-state
…gers.40.deep-sleep-state
…iggers.50.deep-sleep-state2
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.
Looks good to me.
src/service/containers.toit
Outdated
@@ -240,6 +266,23 @@ class ContainerJob extends Job: | |||
stringify -> string: | |||
return "container:$name" | |||
|
|||
deep-sleep-state -> any: | |||
job-state := super |
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.
job-state <> deep-sleep-state
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.
changed to state
.
src/service/containers.toit
Outdated
deep-sleep-state -> any: | ||
job-state := super | ||
if not override-triggers_: return job-state | ||
return { |
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.
This looks clean, but we're only storing in RTC memory so we don't have to worry about upgradability. Maybe just stick to lists that are much shorter when encoded?
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.
done.
@@ -24,3 +24,7 @@ class ContainerCurrent implements artemis.Container: | |||
triggers -> List: | |||
encoded-triggers := client_.container-current-triggers | |||
return encoded-triggers.map: artemis.Trigger.decode it | |||
|
|||
set-next-start-triggers triggers/List -> none: |
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.
triggers can be null
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.
done.
src/service/containers.toit
Outdated
kind := trigger.kind | ||
if kind == Trigger.KIND-BOOT: | ||
trigger-boot = true | ||
if kind == Trigger.KIND-INSTALL: |
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.
else if
here and elsewhere.
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.
done.
src/service/containers.toit
Outdated
@@ -219,6 +244,7 @@ class ContainerJob extends Job: | |||
is-background_/bool := false | |||
|
|||
triggers_/Triggers := Triggers | |||
override_triggers_/Triggers? := null |
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'd consider calling these triggers-override_
, but if nothing else I'd kebabify.
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.
done.
src/service/containers.toit
Outdated
return triggers_.to-encoded-list | ||
return active-triggers.to-encoded-list | ||
|
||
active-triggers -> Triggers: |
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.
Active sounds a little bit like they've fired already. Maybe effective? Also, I'd consider just having a field with the effective triggers and then have the default ones hide behind that.
triggers_/Triggers
triggers-default_/Triggers := Triggers
Fewer null checks and helper methods.
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.
Changed to two fields, where triggers-armed_
is usually identical to the triggers-default_
but may be overridden.
If $triggers is set to null, then the original triggers are | ||
restored. | ||
*/ | ||
set-next-start-triggers triggers/List? -> none |
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.
Not sure yet, but I feel like I want to couple this with the container restart mechanism.
artemis.Container.current.restart --triggers=[ ... ] --delay=(Duration --s=10)
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 can add this functionality, but Consibio wants to be able to disable a pin-trigger. They might not necessarily need to restart at that point.
It's also easier if the program decides at start-up what its next triggers should be. (Or maybe just after connecting...).
If we force a restart when setting the trigger, then it's quite easy to forget it, or to accidentally not set if if the program crashes...
src/service/service.toit
Outdated
@@ -155,6 +165,9 @@ class ArtemisServiceProvider extends ChannelServiceProvider | |||
container-current-triggers -> List: | |||
unreachable // Here to satisfy the checker. | |||
|
|||
container-current-set-triggers new-triggers/List -> none: | |||
unreachable // Here to satisfy the checker. |
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.
unreachable // Here to satisfy the checker. | |
unreachable // Here to satisfy the checker. |
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.
done.
src/service/service.toit
Outdated
@@ -155,6 +165,9 @@ class ArtemisServiceProvider extends ChannelServiceProvider | |||
container-current-triggers -> List: | |||
unreachable // Here to satisfy the checker. |
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.
unreachable // Here to satisfy the checker. | |
unreachable // Here to satisfy the checker. |
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.
done.
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.
Still looks good.
No description provided.