-
Notifications
You must be signed in to change notification settings - Fork 137
[client] Connector queuing auto backpressure - Scheduler (#6325) #698
Conversation
| try: | ||
| # Calculates the duration period in seconds | ||
| timedelta_adapter = TypeAdapter(datetime.timedelta) | ||
| td = timedelta_adapter.validate_python(duration_period) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the duration_period from "PT5S" to "0" raised an error
duration_period: '0'
Doing this works
| td = timedelta_adapter.validate_python(duration_period) | |
| td = timedelta_adapter.validate_python(int(duration_period)) |
BUT if we doing this, cannot handle the value in ISO8601 format anymore:
But the value of duration_period in int works if it's 0
duration_period: 0
Let's talk about it :)
baebf63 to
57d304a
Compare
|
Tested locally and everything seems good to me, here are different cases I've tested:
Steps to Reproduce and my understanding:
During the test, the connector was modified to run the scheduler as following: def process_message(self):
"""Main process of the connector."""
[...]
def run(self):
self.helper.schedule_iso(
message_callback=self.process_message,
duration_period=self.config.duration_period,
) |
| duration_timedelta = datetime.timedelta(seconds=duration_period_in_seconds) | ||
| next_datetime = datetime.datetime.now() + duration_timedelta | ||
| # Set next_run_datetime | ||
| self.connector_info.next_run_datetime = next_datetime.strftime( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add information as log about the next run here ?
8d6f447 to
51c12b9
Compare
2b4c154 to
fcaabdf
Compare
pycti/api/opencti_api_connector.py
Outdated
| """ | ||
| self.api.app_logger.info("[INFO] Getting connector details ...") | ||
| query = """ | ||
| query GetConnectors($id: String!) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comment: since we get only one connector, I suggest to rename the query name to GetConnector without the s. Or just Connector
…dule_unit, and doc
ad9ca6a to
96077b6
Compare
requirements.txt
Outdated
| python-magic-bin~=0.4.14; sys_platform == 'win32' | ||
| python_json_logger~=2.0.4 | ||
| PyYAML~=6.0 | ||
| pydantic~=2.7.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this dependency seem to break connectors that use older versions of pydantic (1.10.17)
…nCTI-Platform/client-python#698) Co-authored-by: Helene Nguyen <helene.nguyen@filigran.io> (original commit: OpenCTI-Platform/client-python@8ef3069)


Proposed changes
Related issues
Checklist
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...