Skip to content

Instantly share code, notes, and snippets.

@alexnodejs
Last active January 25, 2022 19:50
Show Gist options
  • Save alexnodejs/aa4828f62137e763884b6ae223f83535 to your computer and use it in GitHub Desktop.
Save alexnodejs/aa4828f62137e763884b6ae223f83535 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
const fetchMachine = Machine({
id: 'createApplication',
context: {
microserviceRepositoryName: 'name',
microserviceTemplateRepositoryPath: '/path',
recoveryState: {
creatingResources: {
creatingMicroservice: null,
creatingDatabase: null,
},
},
},
initial: 'creatingResources',
states: {
creatingResources: {
type: 'parallel',
states: {
creatingMicroservice: {
initial: 'creatingConfluenceTemplate',
states: {
creatingConfluenceTemplate: {
initial: 'setup',
entry: 'setCreatingConfluenceTemplateFailureRecoveryState',
states: {
setup: {
always: [
{
target: 'failed',
cond: 'isRetrying',
},
{
target: 'execution',
},
],
},
execution: {
invoke: {
id: 'creatingConfluenceTemplate',
src: 'creatingConfluenceTemplate',
onDone: {
target: 'saveWorkflowSuccessfulTransition',
actions: ['saveConfluenceTemplateName'],
},
onError: {
target: 'saveWorkflowFailedTransition',
},
},
},
saveWorkflowSuccessfulTransition: {
invoke: {
id: 'updateWorkflowState',
src: 'updateWorkflowState',
onDone: {
target: '#microserviceCreated',
},
},
},
saveWorkflowFailedTransition: {
invoke: {
id: 'updateWorkflowState',
src: 'updateWorkflowState',
onDone: {
target: 'failed',
},
onError: {
target: 'failed',
},
},
},
failed: {
on: {
RETRY: 'execution',
},
},
},
},
microserviceCreated: {
id: 'microserviceCreated',
type: 'final',
},
},
},
creatingDatabase: {
initial: 'databaseCreated',
states: {
databaseCreated: {
type: 'final',
},
},
},
},
onDone: {
actions: ['logCompletion'],
},
},
sendingNotifications: {
type: 'final',
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment