Skip to content

Scheduler Redesign #800

@MarkKoz

Description

@MarkKoz

Note: this is written as if #755 has already been merged.

Current Problems

  1. Scheduling different coroutines cannot be done easily
  2. With the inheritance design, classes can't really share a scheduler
  3. There's no way for end users to see errors which occur within tasks

Description

The scheduler currently designed with inheritance. The task scheduled is an abstract method which subclasses have to implemented. This design is restrictive because it only supports that one coroutine for scheduling. Some features may require several different coroutines to be scheduled. While it's possible to defer to other functions inside the abstract method, it gets messy. A better design seems to be to allow specifying the exact coroutine one wishes to schedule.

The above change would remove reliance on an abstract method thus allowing for composition to be used instead of inheritance. This is useful when different code needs to share a scheduler. For example, the ModManagement cog currently relies on the Infractions cog so it can re-schedule infractions if durations are edited. With composition, the scheduler could be created and passed to both cogs when they get instantiated in setup().

Similar to specifying the coroutine to schedule, a callback for exception handling can also be specified. By default the exception will simply be logged. If a user-invoked command scheduled a task which raised an exception, the user won't know about it - the command may fail silently from the user's perspective. In such case, the aforementioned callback would enable a message to be sent to the user. As another example, it could be used to still send a mod log if an automatic expiration of an infraction raised an unhanded exception.


I'm labelling this as "planning" for now to get thoughts on the above. Do you believe these are indeed problems with the current designs? Do you think the proposed changes are good? What other problems can you identify with the scheduler?

Metadata

Metadata

Assignees

Labels

a: backendRelated to internal functionality and utilities (error_handler, logging, security, utils and core)p: 1 - highHigh Prioritys: WIPWork In Progresss: planningDiscussing detailst: featureNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions