TritonDataCenter / node-workflow

Task orchestration, creation and running using NodeJS
MIT License
456 stars 66 forks source link

backend.updateWorkflow() strips chain and onerror function bodies #144

Closed ghost closed 9 years ago

ghost commented 9 years ago

When I use factory.workflow() to create a workflow against the wf-redis-backend module, everything works fine -- body functions get into the workflow definition in redis and the code gets executed by the runner.

When I use backend.updateWorkflow() to update a workflow from a known-valid workflow definition, any functions placed in the chain or the onerror property are stripped.

Is there an alternative in-place update mechanism for workflows that will not break the task functions?

ghost commented 9 years ago

Also it looks like from the docs workflow-redis-backend should be bundled in /lib along with the in-memory backend, but it's not present. Is the npm module wf-redis-backend fully compatible with this version of node-workflow? Could that be why I'm seeing this issue?

ghost commented 9 years ago

I think I figured it out. The factory stringifys all functions before sending them to the backend.createWorkflow() method. There isn't a factory method equivalent for the update operation and the validateTask() method used to convert the functions isn't accessible outside the factory. I can create a PR allowing the factory.workflow() operation to accept a mode of either 'create' or 'update' via opts to conditionally call backend.createWorkflow() or backend.updateWorkflow() depending on the factory method modality. Or if you prefer, would you be able to address the need to send workflow definitions through a more generic transformer before passing them to backend methods? A factory probably isn't the best pattern for an in-place update to an existing entity.