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.
@@ -2,7 +2,11 @@ from enum import Enum
2
2
 
3
3
  class ListeningEvent(Enum):
4
4
  """
5
- Enum representing global listener events.
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 resumes.
20
+ Event triggered when the scheduler is resumed.
17
21
  SCHEDULER_ERROR : str
18
22
  Event triggered when the scheduler encounters an error.
19
- SCHEDULER_STARTED : str
20
- Event triggered when the scheduler starts.
21
- SCHEDULER_SHUTDOWN : str
22
- Event triggered when the scheduler shuts down.
23
- SCHEDULER_PAUSED : str
24
- Event triggered when the scheduler is paused.
25
- SCHEDULER_RESUMED : str
26
- Event triggered when the scheduler resumes.
27
- EXECUTOR_ADDED : str
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
- JOB_SUBMITTED : str
50
- Event triggered when a job is submitted.
51
- JOB_MAX_INSTANCES : str
52
- Event triggered when a job exceeds max instances.
53
- ALL : str
54
- Event triggered for all events.
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
- SCHEDULER_STARTED = "X-ORIONIS-EVENT-SCHEDULER-STARTED"
58
- SCHEDULER_SHUTDOWN = "X-ORIONIS-EVENT-SCHEDULER-SHUTDOWN"
59
- SCHEDULER_PAUSED = "X-ORIONIS-EVENT-SCHEDULER-PAUSED"
60
- SCHEDULER_RESUMED = "X-ORIONIS-EVENT-SCHEDULER-RESUMED"
61
- SCHEDULER_ERROR = "X-ORIONIS-SCHEDULER-ERROR"
62
- EXECUTOR_ADDED = "X-ORIONIS-EVENT-EXECUTOR-ADDED"
63
- EXECUTOR_REMOVED = "X-ORIONIS-EVENT-EXECUTOR-REMOVED"
64
- JOBSTORE_ADDED = "X-ORIONIS-EVENT-JOBSTORE-ADDED"
65
- JOBSTORE_REMOVED = "X-ORIONIS-EVENT-JOBSTORE-REMOVED"
66
- ALL_JOBS_REMOVED = "X-ORIONIS-EVENT-ALL-JOBS-REMOVED"
67
- JOB_ADDED = "X-ORIONIS-EVENT-JOB-ADDED"
68
- JOB_REMOVED = "X-ORIONIS-EVENT-JOB-REMOVED"
69
- JOB_MODIFIED = "X-ORIONIS-EVENT-JOB-MODIFIED"
70
- JOB_EXECUTED = "X-ORIONIS-EVENT-JOB-EXECUTED"
71
- JOB_ERROR = "X-ORIONIS-EVENT-JOB-ERROR"
72
- JOB_MISSED = "X-ORIONIS-EVENT-JOB-MISSED"
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
@@ -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
- The unique identifier or signature for the event. This is typically
27
- used to distinguish between different events in the system.
28
- args : Optional[List[str]]
29
- A list of arguments required by the event. If not provided, an empty
30
- list will be used.
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 constructor does not return any value. It initializes the internal
38
- state of the Event object.
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 implements the IScheduleEventListener interface
353
+ # Validate that the provided listener is an instance of IScheduleEventListener
336
354
  if not isinstance(listener, IScheduleEventListener):
337
- raise CLIOrionisValueError("Listener must implement IScheduleEventListener interface.")
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