Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface for BatchJob strategies #1264

Closed
4 tasks
fPolic opened this issue Mar 28, 2022 · 3 comments · Fixed by #1434
Closed
4 tasks

Interface for BatchJob strategies #1264

fPolic opened this issue Mar 28, 2022 · 3 comments · Fixed by #1434

Comments

@fPolic
Copy link
Contributor

fPolic commented Mar 28, 2022

Goal
Create a common interface that BatchJob strategies implement

DoD

  • Create and export IBatchJobStrategy interface in /interfaces
  • Exports AbstractBatchJobStrategy from same file
  • Strategies loader should register all BatchJobStrategies in an array that can be used from the BatchJobService
  • All handlers should include static props called identifier and batchType which will be used to identify which batch type the handler can be used for

Comments

interface {

  /*
  * Used in the API controller to verify that the `context` param is valid
  */
  validateContext()
  
  /*
  *  Method does the actual processing of the job. Should report back on the progress of the operation.
  */
  processJob()
  
  /*
  *  Method performs the completion of the job. Will not be run if `processJob` has already moved the BatchJob to a `complete` status.
  */
  completeJob()

  /**
   * Validates that the file can be used for processJob
   */
  validateFile(fileLocation: string)

  /**
   * Builds and returns a template file that can be downloaded and filled in
   */
  buildTemplate()
}
@srindom
Copy link
Collaborator

srindom commented Mar 29, 2022

We might need to extend the interface a bit - let's include:

/**
 * Validates that the file can be used for processJob
 */
validateFile(fileLocation: string)

/**
 * Builds and returns a template file that can be downloaded and filled in
 */
buildTemplate()

Also, all handlers should include static props called identifier and batchType which will be used to identify which batch type the handler can be used for.

E.g.

class ProductImportHandler extends AbstractBatchJobHandler {
  static identifier = "my-handler"
  static batchType = "product_import"
}

@srindom
Copy link
Collaborator

srindom commented Mar 29, 2022

Also, I think we should maybe rename these to *Strategy. E.g. ProductImportStrategy just to keep consistent with an existing pattern instead of introducing a new one - wdyt?

cc: @kasperkristensen

@srindom
Copy link
Collaborator

srindom commented Mar 29, 2022

  • Create and export IBatchJobStrategy interface in /interfaces
  • Exports AbstractBatchJobStrategy from same file
  • Strategies loader should register all BatchJobStrategies in an array that can be used from the BatchJobService

@olivermrbl olivermrbl changed the title Batch job *Handlers Batch job *Strategies Apr 24, 2022
@pKorsholm pKorsholm self-assigned this Apr 26, 2022
@olivermrbl olivermrbl changed the title Batch job *Strategies Batch job *Strategy interface May 8, 2022
@olivermrbl olivermrbl changed the title Batch job *Strategy interface Interface for BatchJob strategies May 8, 2022
@olivermrbl olivermrbl linked a pull request May 8, 2022 that will close this issue
@srindom srindom closed this as completed Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants