yorc icon indicating copy to clipboard operation
yorc copied to clipboard

Maybe refactor worker + task code to use polymorphism

Open feloxyde opened this issue 5 years ago • 2 comments

Is your refactor request related to a problem? Please describe. The current construction of Worker + Task code (especially worker.handleExecution method) is implemented as : Tasks have a "type", and Worker uses a "switch" to call the right method to use to run the task. This code could, maybe, be more elegant using interface and polymorphism, and thus allow easier implementation of new task types.

Describe the solution you'd like Define a "Task" interface, with a method like "run" or something like this, and have each task type implement it. Then the runner has to simply call "run" method instead of checking the type of the Task.

feloxyde avatar Apr 05 '19 09:04 feloxyde

We identified a major refactoring on tasks/workers for a future 4.0 release of Yorc. Keep in mind that we expect to not break dependencies across minor releases (see https://golang.org/doc/go1compat) so till 4.0 changes should be limited to package unexported stuff. Last warning the worker code is a bit touchy as it requires synchronization between Yorc instances especially when handling workflows steps that may be executed on several instances. This part of code is very sensitive and should be modified carefully (and well tested in live).

loicalbertin avatar Apr 05 '19 09:04 loicalbertin

Oh right, I'll just leave this here waiting for the 4.0 release. I was expecting something like this to be, since workers are concurrent execution, thank you for removing "good first issue" label then !

feloxyde avatar Apr 05 '19 13:04 feloxyde