Skip to content

feat(drivers): refactor drivers #1127

Description

@ocervell

We would like to remove hooks/ and replace it with drivers/ directory to align better with what we call them in the docs, and make a few changes to drivers:

  • A driver should be a class like:
class GCSDriver(object):

    def __init__(self, bucket_name=CONFIG.addons.gcs.bucket_name):
          self.bucket_name = bucket_name

    @property
    def hooks(self):
         return {
           Task: {
               'on_item': [self.on_item]
            },
        }

    def check(self) -> Boolean:
         # check we can read / write to the bucket
         return True

    def on_item(self, runner, item):
         # existing process_item code
         return item

    def upload_blob(self, source_file_name, destination_blob_name):
          # existing upload blob code, adjust with self stuff
    ...
  • A runner should be instanciated like:
gcs_driver = GCSDriver(bucket_name='test_bucket')
runner = Runner(<existing_params>, drivers=[gcs_driver])
  • and the CLI existing command wouldn't change from what it is now:
secator x httpx --driver gcs <TARGET>

@claude please investigate and implement this. Consider the case where the runner instance is passed to a remote worker: will it serialize properly or not ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions