smashing icon indicating copy to clipboard operation
smashing copied to clipboard

Build a Job class

Open terraboops opened this issue 8 years ago • 5 comments

Currently, jobs are a ruby file that invoke Rufus scheduler directly and then call send_event. It would be much better for many reasons if there was a superclass which users could subclass. The subclass would be responsible for providing the implementation for a 'run' method which would return a value to the caller.

Benefits:

  • Abstracts the use of Rufus, making it easier to update or replace it in the future
  • Enhanced testability of Job logic -- simply mock job dependencies and assert the output
  • Less confusion for beginners about what is happening when (dashboard start time vs. job runtime)

terraboops avatar Jan 06 '17 05:01 terraboops

Good idea. I like specially abstraction. I have a pattern that I use with YAML files and some boilerplate code for encryption (simple base64 by default, but with support to Amazon KMS too). When vacation is over (February hooray! :tada: ) I will file an issue for that. But having a Job class could be useful for that too, so my +1

kinow avatar Jan 06 '17 09:01 kinow

Maybe try to add loading and passing through settings in a unified way too. This way we might prevent a lot of copy pastes and hardcoded configuration in the jobs, making them less re-useable

vStone avatar Jan 12 '17 11:01 vStone

@vStone the way I'm configuring my jobs now is with a dashboard.yml file or similar in the top level. e.g. (writing without testing the syntax):

- bitbucket:
  - repositories:
    - a
    - b
  - credentials:
    - username: abc
    - password: abc
- testlink:
    - credentials:
      - username: abc

I will have access to the working dashboard in one week and will update the ticket with the complete set up. But basically, each job imports an utility class (that could be part of smashing core if others find it useful) and this class has the methods to parse the YAML.

kinow avatar Jan 12 '17 13:01 kinow

can you use the dashing jobs generator with smashing?

JoshuaEdwards1991 avatar Jan 12 '17 14:01 JoshuaEdwards1991

@JoshuaEdwards1991 what do you mean by using the dashing jobs generator with smashing?

At this point, Dashing and Smashing are quite similar so you should be able to generate jobs using Smashing, just as you would in Dashing.

suhussai avatar Feb 01 '17 01:02 suhussai