-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Add SchedulerAgent, which periodically runs other agents. #459
Conversation
This is very interesting. Do you see different types of Agents needing to trigger other Agents as well? Generally, Agents are triggered by incoming events, but I can imagine that having a side-channel method of running Agents could be useful in the future. If we're going to make it generic-- chains and targets-- then we should be sure that there are enough use cases beyond the SchedulerAgent. Otherwise, a new Schedule object could have many Agents, but not be an Agent itself. What other uses do we foresee? |
@cantino Yes, I have at least two in my mind as I named above. Their supposed use cases include the following:
|
The only action that these "runner" agents take at the moment is "run", but there could also be "disable" and "enable". Agents that can run other agents may have |
That makes sense. I'll play with this and do a deeper review of the code soon! |
This is done in preparation for adding an ability for an agent to enable or disable other agents other than running.
# SchedulerAgent. By default, the use of the "second" field is | ||
# restricted so that any value other than a single zero (which means | ||
# "on the minute") is disallowed. | ||
ENABLE_SECOND_PRECISION_SCHEDULE=false |
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.
Is this to prevent DOS?
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, you can still create as many agents as you want, though, I suppose only allowing an agent to run on the minute would demotivate potential abusers. Should I note that here?
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 guess? I suppose we could allow every 15 or 30 seconds. What do you think?
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.
That is fine as long as you can document that nicely in the description. I cheated by omitting the seconds part completely. 😁
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.
OK, multiples of fifteen are now allowed even when the option is disabled (default).
Conflicts: app/helpers/agent_helper.rb db/schema.rb
@cantino The s/target/control_target/g part is done. What do you think about the table name? #459 (comment) |
|
||
class Job | ||
# Store an ID of SchedulerAgent in this job. | ||
def scheduler_agent_id= id |
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.
()
please around the arguments.
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.
()!
Conflicts: db/schema.rb
Looks great to me! Let me deploy this to my setup and let it run for a few days, then I think we'd be good to merge. Is there anything else you wanted to add to this? |
If controlling Agents have a "Control targets" list, why do other Agents need to have a "Controllers" list. It seems like it'd make sense to have one or the other. |
@cantino I'll make the field read-only then. When cloning an agent that has controllers, it may be important for user to see them in the form before saving it. |
@cantino I think it's done by now! |
Awesome! I'll play with it for a day or two and we can get it out :) |
Seems to be working well! |
OK, so I'm going to merge this later and take the next step forward! |
Sounds good! |
Done! Should cover #67. |
This thread was closed, but I've added Agent ideas found here to the list in #353. |
This is the core part of the solution to #444. As the first step, I've implemented SchedulerAgent that supports cron-style schedule. User can create SchedulerAgents as many as they want and bind target Agents to it. A master scheduler job in HuginnScheduler periodically checks for SchedulerAgents to create/update/delete the corresponding jobs as necessary.
We can add some additional agents later if needs be:
How do you feel about this direction?