orionis 0.513.0__py3-none-any.whl → 0.514.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orionis/console/base/scheduler_event_listener.py +9 -10
- orionis/console/commands/scheduler_list.py +3 -3
- orionis/console/commands/scheduler_work.py +19 -16
- orionis/console/contracts/schedule.py +210 -44
- orionis/console/contracts/schedule_event_listener.py +0 -34
- orionis/console/entities/job_modified.py +1 -2
- orionis/console/enums/event.py +19 -11
- orionis/console/enums/listener.py +44 -56
- orionis/console/tasks/event.py +31 -13
- orionis/console/tasks/schedule.py +589 -360
- orionis/metadata/framework.py +1 -1
- {orionis-0.513.0.dist-info → orionis-0.514.0.dist-info}/METADATA +1 -1
- {orionis-0.513.0.dist-info → orionis-0.514.0.dist-info}/RECORD +17 -17
- {orionis-0.513.0.dist-info → orionis-0.514.0.dist-info}/WHEEL +0 -0
- {orionis-0.513.0.dist-info → orionis-0.514.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.513.0.dist-info → orionis-0.514.0.dist-info}/top_level.txt +0 -0
- {orionis-0.513.0.dist-info → orionis-0.514.0.dist-info}/zip-safe +0 -0
|
@@ -2,7 +2,11 @@ from enum import Enum
|
|
|
2
2
|
|
|
3
3
|
class ListeningEvent(Enum):
|
|
4
4
|
"""
|
|
5
|
-
|
|
5
|
+
Enumeration of events related to a scheduler and its jobs.
|
|
6
|
+
|
|
7
|
+
This class defines various events that can occur during the lifecycle of a scheduler
|
|
8
|
+
and its associated jobs. These events can be used to monitor and respond to changes
|
|
9
|
+
in the scheduler's state or the execution of jobs.
|
|
6
10
|
|
|
7
11
|
Attributes
|
|
8
12
|
----------
|
|
@@ -13,63 +17,47 @@ class ListeningEvent(Enum):
|
|
|
13
17
|
SCHEDULER_PAUSED : str
|
|
14
18
|
Event triggered when the scheduler is paused.
|
|
15
19
|
SCHEDULER_RESUMED : str
|
|
16
|
-
Event triggered when the scheduler
|
|
20
|
+
Event triggered when the scheduler is resumed.
|
|
17
21
|
SCHEDULER_ERROR : str
|
|
18
22
|
Event triggered when the scheduler encounters an error.
|
|
19
|
-
|
|
20
|
-
Event triggered
|
|
21
|
-
|
|
22
|
-
Event triggered
|
|
23
|
-
|
|
24
|
-
Event triggered when
|
|
25
|
-
|
|
26
|
-
Event triggered when
|
|
27
|
-
|
|
28
|
-
Event triggered when an executor is added.
|
|
29
|
-
EXECUTOR_REMOVED : str
|
|
30
|
-
Event triggered when an executor is removed.
|
|
31
|
-
JOBSTORE_ADDED : str
|
|
32
|
-
Event triggered when a job store is added.
|
|
33
|
-
JOBSTORE_REMOVED : str
|
|
34
|
-
Event triggered when a job store is removed.
|
|
35
|
-
ALL_JOBS_REMOVED : str
|
|
36
|
-
Event triggered when all jobs are removed.
|
|
37
|
-
JOB_ADDED : str
|
|
38
|
-
Event triggered when a job is added.
|
|
39
|
-
JOB_REMOVED : str
|
|
40
|
-
Event triggered when a job is removed.
|
|
41
|
-
JOB_MODIFIED : str
|
|
42
|
-
Event triggered when a job is modified.
|
|
43
|
-
JOB_EXECUTED : str
|
|
44
|
-
Event triggered when a job is executed.
|
|
45
|
-
JOB_ERROR : str
|
|
46
|
-
Event triggered when a job encounters an error.
|
|
47
|
-
JOB_MISSED : str
|
|
23
|
+
JOB_BEFORE : str
|
|
24
|
+
Event triggered before a job is executed.
|
|
25
|
+
JOB_AFTER : str
|
|
26
|
+
Event triggered after a job is executed.
|
|
27
|
+
JOB_ON_SUCCESS : str
|
|
28
|
+
Event triggered when a job completes successfully.
|
|
29
|
+
JOB_ON_FAILURE : str
|
|
30
|
+
Event triggered when a job fails.
|
|
31
|
+
JOB_ON_MISSED : str
|
|
48
32
|
Event triggered when a job is missed.
|
|
49
|
-
|
|
50
|
-
Event triggered when a job
|
|
51
|
-
|
|
52
|
-
Event triggered when a job
|
|
53
|
-
|
|
54
|
-
Event triggered
|
|
33
|
+
JOB_ON_MAXINSTANCES : str
|
|
34
|
+
Event triggered when a job exceeds its maximum allowed instances.
|
|
35
|
+
JOB_ON_PAUSED : str
|
|
36
|
+
Event triggered when a job is paused.
|
|
37
|
+
JOB_ON_RESUMED : str
|
|
38
|
+
Event triggered when a paused job is resumed.
|
|
39
|
+
JOB_ON_REMOVED : str
|
|
40
|
+
Event triggered when a job is removed.
|
|
41
|
+
|
|
42
|
+
Returns
|
|
43
|
+
-------
|
|
44
|
+
str
|
|
45
|
+
The string representation of the event name.
|
|
55
46
|
"""
|
|
56
47
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
JOB_SUBMITTED = "X-ORIONIS-EVENT-JOB-SUBMITTED"
|
|
74
|
-
JOB_MAX_INSTANCES = "X-ORIONIS-EVENT-JOB-MAX-INSTANCES"
|
|
75
|
-
ALL = "X-ORIONIS-EVENT-ALL"
|
|
48
|
+
# Scheduler-related events
|
|
49
|
+
SCHEDULER_STARTED = "schedulerStarted" # Triggered when the scheduler starts
|
|
50
|
+
SCHEDULER_SHUTDOWN = "schedulerShutdown" # Triggered when the scheduler shuts down
|
|
51
|
+
SCHEDULER_PAUSED = "schedulerPaused" # Triggered when the scheduler is paused
|
|
52
|
+
SCHEDULER_RESUMED = "schedulerResumed" # Triggered when the scheduler is resumed
|
|
53
|
+
SCHEDULER_ERROR = "schedulerError" # Triggered when the scheduler encounters an error
|
|
54
|
+
|
|
55
|
+
# Job-related events
|
|
56
|
+
JOB_BEFORE = "before" # Triggered before a job is executed
|
|
57
|
+
JOB_AFTER = "after" # Triggered after a job is executed
|
|
58
|
+
JOB_ON_FAILURE = "onFailure" # Triggered when a job fails
|
|
59
|
+
JOB_ON_MISSED = "onMissed" # Triggered when a job is missed
|
|
60
|
+
JOB_ON_MAXINSTANCES = "onMaxInstances" # Triggered when a job exceeds its max instances
|
|
61
|
+
JOB_ON_PAUSED = "onPaused" # Triggered when a job is paused
|
|
62
|
+
JOB_ON_RESUMED = "onResumed" # Triggered when a paused job is resumed
|
|
63
|
+
JOB_ON_REMOVED = "onRemoved" # Triggered when a job is removed
|
orionis/console/tasks/event.py
CHANGED
|
@@ -20,25 +20,34 @@ class Event(IEvent):
|
|
|
20
20
|
"""
|
|
21
21
|
Initialize a new Event instance.
|
|
22
22
|
|
|
23
|
+
This constructor sets up the initial state of an Event object, including its
|
|
24
|
+
unique signature, arguments, purpose, and other optional attributes such as
|
|
25
|
+
random delay, start and end dates, trigger, details, listener, and maximum
|
|
26
|
+
instances. These attributes define the behavior and metadata of the event.
|
|
27
|
+
|
|
23
28
|
Parameters
|
|
24
29
|
----------
|
|
25
30
|
signature : str
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
purpose : Optional[str], optional
|
|
32
|
-
A human-readable description or purpose for the event, by default None.
|
|
31
|
+
A unique identifier for the event. This is required and must be a non-empty string.
|
|
32
|
+
args : list of str, optional
|
|
33
|
+
A list of arguments associated with the event. Defaults to an empty list if None is provided.
|
|
34
|
+
purpose : str, optional
|
|
35
|
+
A human-readable description or purpose of the event. Defaults to None.
|
|
33
36
|
|
|
34
37
|
Returns
|
|
35
38
|
-------
|
|
36
39
|
None
|
|
37
|
-
This
|
|
38
|
-
|
|
40
|
+
This method does not return any value. It initializes the Event instance.
|
|
41
|
+
|
|
42
|
+
Notes
|
|
43
|
+
-----
|
|
44
|
+
The `__trigger` attribute is initially set to None and can later be configured
|
|
45
|
+
to a Cron, Date, or Interval trigger. Similarly, the `__listener` attribute is
|
|
46
|
+
set to None and can be assigned an instance of `IScheduleEventListener` to handle
|
|
47
|
+
event-specific logic.
|
|
39
48
|
"""
|
|
40
49
|
|
|
41
|
-
# Store the event's signature
|
|
50
|
+
# Store the event's unique signature
|
|
42
51
|
self.__signature: str = signature
|
|
43
52
|
|
|
44
53
|
# Store the event's arguments, defaulting to an empty list if None is provided
|
|
@@ -88,8 +97,12 @@ class Event(IEvent):
|
|
|
88
97
|
# Validate that the signature is set and is a non-empty string
|
|
89
98
|
if not self.__signature:
|
|
90
99
|
raise CLIOrionisValueError("Signature is required for the event.")
|
|
100
|
+
|
|
101
|
+
# Validate arguments
|
|
91
102
|
if not isinstance(self.__args, list):
|
|
92
103
|
raise CLIOrionisValueError("Args must be a list.")
|
|
104
|
+
|
|
105
|
+
# Validate that purpose is a string if it is set
|
|
93
106
|
if self.__purpose is not None and not isinstance(self.__purpose, str):
|
|
94
107
|
raise CLIOrionisValueError("Purpose must be a string or None.")
|
|
95
108
|
|
|
@@ -111,6 +124,10 @@ class Event(IEvent):
|
|
|
111
124
|
if self.__details is not None and not isinstance(self.__details, str):
|
|
112
125
|
raise CLIOrionisValueError("Details must be a string or None.")
|
|
113
126
|
|
|
127
|
+
# Validate that listener is an IScheduleEventListener instance if it is set
|
|
128
|
+
if self.__listener is not None and not isinstance(self.__listener, IScheduleEventListener):
|
|
129
|
+
raise CLIOrionisValueError("Listener must implement IScheduleEventListener interface or be None.")
|
|
130
|
+
|
|
114
131
|
# Construct and return an EventEntity with the current event's attributes
|
|
115
132
|
return EventEntity(
|
|
116
133
|
signature=self.__signature,
|
|
@@ -120,7 +137,8 @@ class Event(IEvent):
|
|
|
120
137
|
start_date=self.__start_date,
|
|
121
138
|
end_date=self.__end_date,
|
|
122
139
|
trigger=self.__trigger,
|
|
123
|
-
details=self.__details
|
|
140
|
+
details=self.__details,
|
|
141
|
+
listener=self.__listener
|
|
124
142
|
)
|
|
125
143
|
|
|
126
144
|
def purpose(
|
|
@@ -332,9 +350,9 @@ class Event(IEvent):
|
|
|
332
350
|
when the event is executed.
|
|
333
351
|
"""
|
|
334
352
|
|
|
335
|
-
# Validate that the provided listener
|
|
353
|
+
# Validate that the provided listener is an instance of IScheduleEventListener
|
|
336
354
|
if not isinstance(listener, IScheduleEventListener):
|
|
337
|
-
raise CLIOrionisValueError("Listener must
|
|
355
|
+
raise CLIOrionisValueError("Listener must be an instance of IScheduleEventListener.")
|
|
338
356
|
|
|
339
357
|
# Assign the listener to the event's internal listener attribute
|
|
340
358
|
self.__listener = listener
|