parsedmarc.source.base
🔗
BaseConfig
🔗
Bases: BaseModel
Base Config for all sources.
New in 9.0.
Job
🔗
Container for a report and the source it came from.
This allows for callbacks / tracking the report as it is processed
ATTRIBUTE | DESCRIPTION |
---|---|
source |
Source that produced this job
TYPE:
|
report |
TYPE:
|
identifier |
identifier for this job, it should be unique for all jobs generated by the source.
TYPE:
|
data |
extra data specific to the source. |
New in 9.0.
Source
🔗
Source(
name: str = "default",
parser: ReportParser | None = None,
config: dict[str, Any] | None = None,
)
Bases: LoggingMixin
Base class for all Sources. Sources generate reports to be consumed by other classes.
New in 9.0.
PARAMETER | DESCRIPTION |
---|---|
name |
profile name for this instance, ideally should be unqiue to easily idenfity this instance and any log messages it produces
TYPE:
|
parser |
parser to use when generating reports
TYPE:
|
config |
config for this instance |
outstanding_jobs
property
🔗
outstanding_jobs: MappingProxyType[str, Job]
Read only view of outstanding jobs
ack_job
🔗
cleanup
🔗
Perform cleanup on this source.
This method is called as a part of self.shutdown
.
Child classes can override this method to implement their own logic.
It is still recomended to call super().cleanup()
.
get_job
🔗
get_job() -> Job | None
Get the next job for this Source
Child classes MUST implement this method.
Child classes must call self.register_job(job)
before returning.
If no Job
is available, child classes should return None
rather than blocking indefinintely.
RETURNS | DESCRIPTION |
---|---|
Job | None
|
The job if one is available, else |
register_job
🔗
register_job(job: Job) -> None
Register a job to this source so we can keep track of it
PARAMETER | DESCRIPTION |
---|---|
job |
the job to register
TYPE:
|
setup
🔗
Perform setup actions to ensure this Source is ready to produce.
Child classes can override this method to implement their own logic.
Child classes should
- check that
self._state == AppState.SHUTDOWN
- set
self._state = AppState.SETTING_UP
- do their setup actions
- if an error occurs set
self._state = AppState.SETUP_ERROR
- otherwise set
self._state = AppState.RUNNING
shutdown
🔗
validate_config
🔗
Validate the config of this instance
Child classes can override this method to implement their own logic.
It is still recomended to call super().validate_config()
.