Skip to content

Instantly share code, notes, and snippets.

@mgreenly
Last active February 28, 2020 05:51
Show Gist options
  • Save mgreenly/95b9e95dd04a388b4992c470607048bc to your computer and use it in GitHub Desktop.
Save mgreenly/95b9e95dd04a388b4992c470607048bc to your computer and use it in GitHub Desktop.
Rules = {
enter: [ 'created' ],
exit: [ 'completed' ],
uncancelable: %w[ completing completed ],
tasks: [
{
name: 'tag',
desc: 'taggable',
transitions: [
{ from: { state: 'tagging', :status: 'pending' }, to: { state: 'tagged' } },
{ from: { state: 'tagging', :status: 'pending' }, to: { state: 'tagged' status: 'aborted' } },
]
},
{
name: 'complete',
desc: 'completable',
transitions: [
{ from: { state: 'completing', :status: 'pending' }, to: { state: 'completed', status: 'succeeded' } },
{ from: { state: 'completing', :status: 'canceling' }, to: { state: 'completed', status: 'canceled' } },
{ from: { state: 'completing', :status: 'aborting' }, to: { state: 'completed', status: 'aborted' } },
]
}
]
transitions: [
# pending
{ retriable: true, from: { state: 'created', status: 'pending' }, to: { state: 'tagging' } }
{ retriable: true, from: { state: 'tagged', status: 'pending' }, to: { state: 'scheduling' } }
# canceling
{ from: { state: 'created', status: 'canceling' }, to: { state: 'completing' } }
{ from: { state: 'tagged', status: 'canceling' }, to: { state: 'completing' } }
# aborting
{ from: { state: 'tagged', status: 'aborting' }, to: { state: 'completing' } }
]
}
---
enter:
- created
exit:
- completed
cancelable:
- created
- tagging
- tagged
tasks:
- name: tag
desc: taggable
transitions:
- from:
state: tagging
status: pending
to:
state: tagged
- name: complete
desc: completable
transitions:
- from:
state: completing
status: pending
to:
state: completed
status: succeeded
- from:
state: completing
status: canceling
to:
state: completed
status: canceled
- from:
state: completing
status: aborting
to:
state: completed
status: aborted
transitions:
- retriable: true
from:
state: created
status: pending
to:
state: tagging
- retriable: true
from:
state: tagged
status: pending
to:
state: scheduling
- from:
state: tagged
status: canceling
to:
state: completing
- from:
state: tagged
status: aborting
to:
state: completing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment