orionis 0.523.0__py3-none-any.whl → 0.525.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.
@@ -1,12 +1,5 @@
1
1
  from orionis.console.contracts.schedule_event_listener import IScheduleEventListener
2
- from orionis.console.entities.job_error import JobError
3
- from orionis.console.entities.job_executed import JobExecuted
4
- from orionis.console.entities.job_max_instances import JobMaxInstances
5
- from orionis.console.entities.job_missed import JobMissed
6
- from orionis.console.entities.job_pause import JobPause
7
- from orionis.console.entities.job_removed import JobRemoved
8
- from orionis.console.entities.job_resume import JobResume
9
- from orionis.console.entities.job_submitted import JobSubmitted
2
+ from orionis.console.entities.event_job import EventJob
10
3
 
11
4
  class BaseScheduleEventListener(IScheduleEventListener):
12
5
  """
@@ -17,119 +10,155 @@ class BaseScheduleEventListener(IScheduleEventListener):
17
10
  specific behavior for each event type.
18
11
  """
19
12
 
20
- async def before(self, event: JobSubmitted, schedule):
13
+ async def before(self, event: EventJob, schedule):
21
14
  """
22
15
  Called before processing a job submission event.
23
16
 
24
17
  Parameters
25
18
  ----------
26
- event : JobSubmitted
27
- The job submission event.
19
+ event : EventJob
20
+ The job submission event containing details about the job.
28
21
  schedule : ISchedule
29
- The associated schedule.
22
+ The associated schedule instance managing the job.
23
+
24
+ Returns
25
+ -------
26
+ None
30
27
  """
31
- pass
28
+ pass # Placeholder for pre-job submission logic
32
29
 
33
- async def after(self, event: JobExecuted, schedule):
30
+ async def after(self, event: EventJob, schedule):
34
31
  """
35
32
  Called after processing a job execution event.
36
33
 
37
34
  Parameters
38
35
  ----------
39
- event : JobExecuted
40
- The job execution event.
36
+ event : EventJob
37
+ The job execution event containing details about the job.
41
38
  schedule : ISchedule
42
- The associated schedule.
39
+ The associated schedule instance managing the job.
40
+
41
+ Returns
42
+ -------
43
+ None
43
44
  """
44
- pass
45
+ pass # Placeholder for post-job execution logic
45
46
 
46
- async def onSuccess(self, event: JobExecuted, schedule):
47
+ async def onSuccess(self, event: EventJob, schedule):
47
48
  """
48
49
  Called when a job is successfully executed.
49
50
 
50
51
  Parameters
51
52
  ----------
52
- event : JobExecuted
53
- The successful job execution event.
53
+ event : EventJob
54
+ The successful job execution event containing details about the job.
54
55
  schedule : ISchedule
55
- The associated schedule.
56
+ The associated schedule instance managing the job.
57
+
58
+ Returns
59
+ -------
60
+ None
56
61
  """
57
- pass
62
+ pass # Placeholder for logic to handle successful job execution
58
63
 
59
- async def onFailure(self, event: JobError, schedule):
64
+ async def onFailure(self, event: EventJob, schedule):
60
65
  """
61
66
  Called when a job execution fails.
62
67
 
63
68
  Parameters
64
69
  ----------
65
- event : JobError
66
- The job error event.
70
+ event : EventJob
71
+ The job error event containing details about the failure.
67
72
  schedule : ISchedule
68
- The associated schedule.
73
+ The associated schedule instance managing the job.
74
+
75
+ Returns
76
+ -------
77
+ None
69
78
  """
70
- pass
79
+ pass # Placeholder for logic to handle job execution failure
71
80
 
72
- async def onMissed(self, event: JobMissed, schedule):
81
+ async def onMissed(self, event: EventJob, schedule):
73
82
  """
74
83
  Called when a job execution is missed.
75
84
 
76
85
  Parameters
77
86
  ----------
78
- event : JobMissed
79
- The missed job event.
87
+ event : EventJob
88
+ The missed job event containing details about the missed execution.
80
89
  schedule : ISchedule
81
- The associated schedule.
90
+ The associated schedule instance managing the job.
91
+
92
+ Returns
93
+ -------
94
+ None
82
95
  """
83
- pass
96
+ pass # Placeholder for logic to handle missed job execution
84
97
 
85
- async def onMaxInstances(self, event: JobMaxInstances, schedule):
98
+ async def onMaxInstances(self, event: EventJob, schedule):
86
99
  """
87
100
  Called when a job exceeds the maximum allowed instances.
88
101
 
89
102
  Parameters
90
103
  ----------
91
- event : JobMaxInstances
92
- The max instances event.
104
+ event : EventJob
105
+ The max instances event containing details about the job.
93
106
  schedule : ISchedule
94
- The associated schedule.
107
+ The associated schedule instance managing the job.
108
+
109
+ Returns
110
+ -------
111
+ None
95
112
  """
96
- pass
113
+ pass # Placeholder for logic to handle max instances exceeded
97
114
 
98
- async def onPaused(self, event: JobPause, schedule):
115
+ async def onPaused(self, event: EventJob, schedule):
99
116
  """
100
117
  Called when the scheduler is paused.
101
118
 
102
119
  Parameters
103
120
  ----------
104
- event : JobPause
105
- The pause event.
121
+ event : EventJob
122
+ The pause event containing details about the scheduler state.
106
123
  schedule : ISchedule
107
- The associated schedule.
124
+ The associated schedule instance managing the jobs.
125
+
126
+ Returns
127
+ -------
128
+ None
108
129
  """
109
- pass
130
+ pass # Placeholder for logic to handle scheduler pause
110
131
 
111
- async def onResumed(self, event: JobResume, schedule):
132
+ async def onResumed(self, event: EventJob, schedule):
112
133
  """
113
134
  Called when the scheduler is resumed.
114
135
 
115
136
  Parameters
116
137
  ----------
117
- event : JobResume
118
- The resume event.
138
+ event : EventJob
139
+ The resume event containing details about the scheduler state.
119
140
  schedule : ISchedule
120
- The associated schedule.
141
+ The associated schedule instance managing the jobs.
142
+
143
+ Returns
144
+ -------
145
+ None
121
146
  """
122
- pass
147
+ pass # Placeholder for logic to handle scheduler resume
123
148
 
124
- async def onRemoved(self, event: JobRemoved, schedule):
149
+ async def onRemoved(self, event: EventJob, schedule):
125
150
  """
126
151
  Called when a job is removed from the scheduler.
127
152
 
128
153
  Parameters
129
154
  ----------
130
- event : JobRemoved
131
- The job removal event.
155
+ event : EventJob
156
+ The job removal event containing details about the removed job.
132
157
  schedule : ISchedule
133
- The associated schedule.
158
+ The associated schedule instance managing the jobs.
159
+
160
+ Returns
161
+ -------
162
+ None
134
163
  """
135
- pass
164
+ pass # Placeholder for logic to handle job removal
@@ -1,12 +1,6 @@
1
1
  from abc import ABC, abstractmethod
2
- from orionis.console.entities.job_error import JobError
3
- from orionis.console.entities.job_executed import JobExecuted
4
- from orionis.console.entities.job_max_instances import JobMaxInstances
5
- from orionis.console.entities.job_missed import JobMissed
6
- from orionis.console.entities.job_pause import JobPause
7
- from orionis.console.entities.job_removed import JobRemoved
8
- from orionis.console.entities.job_resume import JobResume
9
- from orionis.console.entities.job_submitted import JobSubmitted
2
+
3
+ from orionis.console.entities.event_job import EventJob
10
4
 
11
5
  class IScheduleEventListener(ABC):
12
6
  """
@@ -14,273 +8,163 @@ class IScheduleEventListener(ABC):
14
8
  """
15
9
 
16
10
  @abstractmethod
17
- async def before(self, event: JobSubmitted, schedule):
11
+ async def before(self, event: EventJob, schedule):
18
12
  """
19
- Hook method called before the main event handling logic.
20
-
21
- This method is invoked prior to processing the event, allowing for any
22
- pre-processing or setup tasks to be performed. It can be overridden to
23
- implement custom logic that should execute before the event is handled.
13
+ Called before processing a job submission event.
24
14
 
25
15
  Parameters
26
16
  ----------
27
- event : JobSubmitted
28
- The event object that is about to be processed. This contains
29
- information about the job submission.
17
+ event : EventJob
18
+ The job submission event containing details about the job.
30
19
  schedule : ISchedule
31
- The schedule object associated with the event. This provides
32
- context about the scheduling system.
20
+ The associated schedule instance managing the job.
33
21
 
34
22
  Returns
35
23
  -------
36
24
  None
37
- This method does not return any value.
38
-
39
- Notes
40
- -----
41
- Override this method to define actions or checks that should occur
42
- before the event is processed.
43
25
  """
44
-
45
- # This is an abstract method, so it does not contain any implementation.
46
- # Subclasses must override this method to provide specific behavior.
47
26
  pass
48
27
 
49
28
  @abstractmethod
50
- async def after(self, event: JobExecuted, schedule):
29
+ async def after(self, event: EventJob, schedule):
51
30
  """
52
- Hook method called after an event is processed.
53
-
54
- This method is invoked once the event processing is complete, allowing
55
- for any post-processing or cleanup tasks to be performed. It can be
56
- overridden to implement custom logic that should execute after the
57
- event is handled.
31
+ Called after processing a job execution event.
58
32
 
59
33
  Parameters
60
34
  ----------
61
- event : JobExecuted
62
- The event object that was processed. This contains information
63
- about the job execution, such as its status and metadata.
35
+ event : EventJob
36
+ The job execution event containing details about the job.
64
37
  schedule : ISchedule
65
- The schedule object associated with the event. This provides
66
- context about the scheduling system and its state.
38
+ The associated schedule instance managing the job.
67
39
 
68
40
  Returns
69
41
  -------
70
42
  None
71
- This method does not return any value.
72
-
73
- Notes
74
- -----
75
- Override this method to define actions or checks that should occur
76
- after the event is processed, such as logging, resource cleanup, or
77
- triggering subsequent tasks.
78
43
  """
79
-
80
- # This is an abstract method, so it does not contain any implementation.
81
- # Subclasses must override this method to provide specific behavior.
82
44
  pass
83
45
 
84
46
  @abstractmethod
85
- async def onFailure(self, event: JobError, schedule):
47
+ async def onSuccess(self, event: EventJob, schedule):
86
48
  """
87
- Handle the event when a failure occurs during event processing.
88
-
89
- This method is invoked whenever an error or failure occurs during the
90
- processing of an event. It allows for custom error handling logic to be
91
- implemented, such as logging the error, notifying relevant parties, or
92
- performing cleanup tasks. Subclasses should override this method to
93
- define specific actions to take in response to failures.
49
+ Called when a job is successfully executed.
94
50
 
95
51
  Parameters
96
52
  ----------
97
- event : JobError
98
- The event object containing detailed information about the failure,
99
- including the error message, stack trace, and any relevant metadata.
53
+ event : EventJob
54
+ The successful job execution event containing details about the job.
100
55
  schedule : ISchedule
101
- The schedule object associated with the event, providing context
102
- about the scheduling system and its state at the time of the failure.
56
+ The associated schedule instance managing the job.
103
57
 
104
58
  Returns
105
59
  -------
106
60
  None
107
- This method does not return any value. It is intended for handling
108
- side effects or performing actions in response to the failure.
109
-
110
- Notes
111
- -----
112
- Override this method to implement specific error handling logic that
113
- aligns with the application's requirements.
114
61
  """
115
-
116
- # This is an abstract method, so it does not contain any implementation.
117
- # Subclasses must override this method to provide specific behavior.
118
62
  pass
119
63
 
120
64
  @abstractmethod
121
- async def onMissed(self, event: JobMissed, schedule):
65
+ async def onFailure(self, event: EventJob, schedule):
122
66
  """
123
- Handle the event triggered when an expected job execution is missed.
124
-
125
- This method is invoked whenever a scheduled job is missed, allowing for
126
- custom handling logic to be implemented. Subclasses should override this
127
- method to define specific actions to take in response to missed events,
128
- such as logging, notifications, or corrective measures.
67
+ Called when a job execution fails.
129
68
 
130
69
  Parameters
131
70
  ----------
132
- event : JobMissed
133
- The event object containing details about the missed job, including
134
- its metadata and the reason it was missed.
71
+ event : EventJob
72
+ The job error event containing details about the failure.
135
73
  schedule : ISchedule
136
- The schedule object associated with the event, providing context
137
- about the scheduling system and its state at the time of the missed event.
74
+ The associated schedule instance managing the job.
138
75
 
139
76
  Returns
140
77
  -------
141
78
  None
142
- This method does not return any value. It is intended for handling
143
- side effects or performing actions in response to the missed event.
144
-
145
- Notes
146
- -----
147
- Override this method to implement specific logic that aligns with the
148
- application's requirements for handling missed job executions.
149
79
  """
150
-
151
- # Abstract method: Subclasses must provide an implementation for this.
152
80
  pass
153
81
 
154
82
  @abstractmethod
155
- async def onMaxInstances(self, event: JobMaxInstances, schedule):
83
+ async def onMissed(self, event: EventJob, schedule):
156
84
  """
157
- Handle the event triggered when a job exceeds the maximum allowed instances.
158
-
159
- This method is invoked whenever a job attempts to run but is blocked
160
- because it has reached its maximum number of concurrent instances.
161
- Subclasses should override this method to define specific actions to
162
- take in response to this event, such as logging, notifications, or
163
- implementing backoff strategies.
85
+ Called when a job execution is missed.
164
86
 
165
87
  Parameters
166
88
  ----------
167
- event : JobMaxInstances
168
- The event object containing details about the job that exceeded
169
- its maximum instances, including its metadata and the configured limit.
89
+ event : EventJob
90
+ The missed job event containing details about the missed execution.
170
91
  schedule : ISchedule
171
- The schedule object associated with the event, providing context
172
- about the scheduling system and its state at the time of the event.
92
+ The associated schedule instance managing the job.
173
93
 
174
94
  Returns
175
95
  -------
176
96
  None
177
- This method does not return any value. It is intended for handling
178
- side effects or performing actions in response to the max instances event.
179
-
180
- Notes
181
- -----
182
- Override this method to implement specific logic that aligns with the
183
- application's requirements for handling jobs that exceed their maximum instances.
184
97
  """
185
-
186
- # Abstract method: Subclasses must provide an implementation for this.
187
98
  pass
188
99
 
189
100
  @abstractmethod
190
- async def onPaused(self, event: JobPause, schedule):
101
+ async def onMaxInstances(self, event: EventJob, schedule):
191
102
  """
192
- Handle the event triggered when the scheduler is paused.
193
-
194
- This method is invoked whenever the scheduler is paused, allowing for
195
- custom handling logic to be implemented. Subclasses should override this
196
- method to define specific actions to take in response to the pause event,
197
- such as logging, notifications, or resource management.
103
+ Called when a job exceeds the maximum allowed instances.
198
104
 
199
105
  Parameters
200
106
  ----------
201
- event : JobPause
202
- The event object containing details about the pause event.
107
+ event : EventJob
108
+ The max instances event containing details about the job.
203
109
  schedule : ISchedule
204
- The schedule object associated with the event, providing context
205
- about the scheduling system and its state at the time of the pause event.
110
+ The associated schedule instance managing the job.
206
111
 
207
112
  Returns
208
113
  -------
209
114
  None
210
- This method does not return any value. It is intended for handling
211
- side effects or performing actions in response to the pause event.
212
-
213
- Notes
214
- -----
215
- Override this method to implement specific logic that aligns with the
216
- application's requirements for handling scheduler pause events.
217
115
  """
218
-
219
- # Abstract method: Subclasses must provide an implementation for this.
220
116
  pass
221
117
 
222
118
  @abstractmethod
223
- async def onResumed(self, event: JobResume, schedule):
119
+ async def onPaused(self, event: EventJob, schedule):
224
120
  """
225
- Handle the event triggered when the scheduler is resumed.
226
-
227
- This method is invoked whenever the scheduler is resumed, allowing for
228
- custom handling logic to be implemented. Subclasses should override this
229
- method to define specific actions to take in response to the resume event,
230
- such as logging, notifications, or resource management.
121
+ Called when the scheduler is paused.
231
122
 
232
123
  Parameters
233
124
  ----------
234
- event : JobResume
235
- The event object containing details about the resume event.
125
+ event : EventJob
126
+ The pause event containing details about the scheduler state.
236
127
  schedule : ISchedule
237
- The schedule object associated with the event, providing context
238
- about the scheduling system and its state at the time of the resume event.
128
+ The associated schedule instance managing the jobs.
239
129
 
240
130
  Returns
241
131
  -------
242
132
  None
243
- This method does not return any value. It is intended for handling
244
- side effects or performing actions in response to the resume event.
245
-
246
- Notes
247
- -----
248
- Override this method to implement specific logic that aligns with the
249
- application's requirements for handling scheduler resume events.
250
133
  """
251
-
252
- # Abstract method: Subclasses must provide an implementation for this.
253
134
  pass
254
135
 
255
136
  @abstractmethod
256
- async def onRemoved(self, event: JobRemoved, schedule):
137
+ async def onResumed(self, event: EventJob, schedule):
257
138
  """
258
- Handle the event triggered when a job is removed from the scheduler.
259
-
260
- This method is invoked whenever a job is removed, allowing for custom
261
- handling logic to be implemented. Subclasses should override this method
262
- to define specific actions to take in response to the job removal event,
263
- such as logging, notifications, or resource cleanup.
139
+ Called when the scheduler is resumed.
264
140
 
265
141
  Parameters
266
142
  ----------
267
- event : JobRemoved
268
- The event object containing details about the removed job.
143
+ event : EventJob
144
+ The resume event containing details about the scheduler state.
269
145
  schedule : ISchedule
270
- The schedule object associated with the event, providing context
271
- about the scheduling system and its state at the time of the job removal.
146
+ The associated schedule instance managing the jobs.
272
147
 
273
148
  Returns
274
149
  -------
275
150
  None
276
- This method does not return any value. It is intended for handling
277
- side effects or performing actions in response to the job removal event.
151
+ """
152
+ pass
278
153
 
279
- Notes
280
- -----
281
- Override this method to implement specific logic that aligns with the
282
- application's requirements for handling job removal events.
154
+ @abstractmethod
155
+ async def onRemoved(self, event: EventJob, schedule):
283
156
  """
157
+ Called when a job is removed from the scheduler.
284
158
 
285
- # Abstract method: Subclasses must provide an implementation for this.
159
+ Parameters
160
+ ----------
161
+ event : EventJob
162
+ The job removal event containing details about the removed job.
163
+ schedule : ISchedule
164
+ The associated schedule instance managing the jobs.
165
+
166
+ Returns
167
+ -------
168
+ None
169
+ """
286
170
  pass
@@ -0,0 +1,60 @@
1
+ from dataclasses import dataclass
2
+ from datetime import datetime
3
+ from typing import Any, Callable, Dict, Optional, Tuple
4
+
5
+ @dataclass(kw_only=True)
6
+ class EventJob:
7
+ """
8
+ Represents the main properties of a job in APScheduler.
9
+
10
+ Attributes
11
+ ----------
12
+ id : str
13
+ Unique identifier for the job.
14
+ name : Optional[str]
15
+ Human-readable name for the job. Can be None if not specified.
16
+ func : Callable[..., Any]
17
+ The function or coroutine to be executed by the job.
18
+ args : Tuple[Any, ...]
19
+ Positional arguments to be passed to the function.
20
+ trigger : Any
21
+ The trigger that determines the job's execution schedule
22
+ (e.g., IntervalTrigger, CronTrigger, etc.).
23
+ executor : str
24
+ Alias of the executor that will run the job.
25
+ jobstore : str
26
+ Alias of the job store where the job is stored.
27
+ misfire_grace_time : Optional[int]
28
+ Grace period in seconds for handling missed executions.
29
+ If None, no grace period is applied.
30
+ max_instances : int
31
+ Maximum number of concurrent instances of the job allowed.
32
+ coalesce : bool
33
+ Whether to merge pending executions into a single execution.
34
+ next_run_time : Optional[datetime]
35
+ The next scheduled execution time of the job. Can be None if the job is paused or unscheduled.
36
+
37
+ Returns
38
+ -------
39
+ None
40
+ This class is a data container and does not return any value.
41
+ """
42
+ id: str
43
+ code: int = 0
44
+ name: Optional[str] = None
45
+ func: Callable[..., Any] = None
46
+ args: Tuple[Any, ...] = ()
47
+ trigger: Any = None
48
+ executor: str = 'default'
49
+ jobstore: str = 'default'
50
+ misfire_grace_time: Optional[int] = None
51
+ max_instances: int = 1
52
+ coalesce: bool = False
53
+ next_run_time: Optional[datetime] = None
54
+ exception: Optional[BaseException] = None
55
+ traceback: Optional[str] = None
56
+ retval: Optional[Any] = None
57
+ purpose: Optional[str] = None
58
+ start_date: Optional[datetime] = None
59
+ end_date: Optional[datetime] = None
60
+ details: Optional[str] = None
@@ -0,0 +1,19 @@
1
+ from dataclasses import dataclass
2
+ from typing import Optional
3
+ from orionis.console.entities.scheduler_event_data import SchedulerEventData
4
+
5
+ @dataclass(kw_only=True)
6
+ class SchedulerError(SchedulerEventData):
7
+ """
8
+ Represents an event triggered when the scheduler is paused.
9
+
10
+ This class is a data structure that inherits from `SchedulerEventData`
11
+ and is used to encapsulate information related to the scheduler pause event.
12
+
13
+ Attributes
14
+ ----------
15
+ (Inherited from SchedulerEventData)
16
+ """
17
+
18
+ exception: Optional[BaseException] = None # Exception that caused the scheduler error
19
+ traceback: Optional[str] = None # Traceback information related to the scheduler error
@@ -16,9 +16,6 @@ class SchedulerEventData:
16
16
  code : int
17
17
  A numeric code that uniquely identifies the type of event within the
18
18
  scheduler system.
19
- alias : str, optional
20
- An optional string providing additional context or identifying specific
21
- components (e.g., executors or job stores) related to the event.
22
19
 
23
20
  Returns
24
21
  -------
@@ -26,8 +23,6 @@ class SchedulerEventData:
26
23
  An instance of the `SchedulerEventData` class containing the event code
27
24
  and optional alias.
28
25
  """
26
+
29
27
  # Numeric code representing the type of event
30
28
  code: int
31
-
32
- # Optional alias for additional context about the event
33
- alias: Optional[str] = None
@@ -13,5 +13,5 @@ class SchedulerPaused(SchedulerEventData):
13
13
  ----------
14
14
  (Inherited from SchedulerEventData)
15
15
  """
16
- # No additional attributes or methods are defined here, as this class
17
- # serves as a specialized event marker for when the scheduler is paused.
16
+
17
+ time: str # Time when the scheduler was paused