Skip to content
This repository has been archived by the owner on Oct 18, 2019. It is now read-only.

Feature: Move order into a placed state #66

Merged
merged 7 commits into from
Jun 5, 2018

Conversation

treygriffith
Copy link
Member

@treygriffith treygriffith commented May 31, 2018

Description

This PR adds a placeholder for the placed state transition and adds background error handling for individual orders to handle the case where the order is rejected while being placed.

It also moves state machines to their own directory, since it is really outside the scope of simply the block order worker

Related PRs

None

Todos

  • Tests
  • Documentation
  • Link to Trello

@treygriffith
Copy link
Member Author

@treygriffith
Copy link
Member Author

place order

1 similar comment
@treygriffith
Copy link
Member Author

place order

*/
nextTransition: function (transitionName, ...args) {
this.logger.debug(`Queuing transition: ${transitionName}`)
process.nextTick(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the reasoning for using nextTick here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't move to another transition while you're still in one. nextTick gets you out of the current transition. See this issue: jakesgordon/javascript-state-machine#143

let error

if (this.error) {
error = this.error.message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would an error not have a message in our code? Do our custom errors not implement this correctly?

}

const { state, history } = this
let error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] would change this to errorMessage to be more specific


const stateMachine = { state, history, error }

const value = JSON.stringify(Object.assign(valueObject, { __stateMachine: stateMachine }))
Copy link
Contributor

@dannypaz dannypaz Jun 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need to for this PR, but would be worth it to throw this into its own serialize/deserialize method, in the same way we have fromStore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was part of the desire for #67

@dannypaz
Copy link
Contributor

dannypaz commented Jun 5, 2018

LGTM

@treygriffith treygriffith merged commit ba0a8d3 into master Jun 5, 2018
@treygriffith treygriffith deleted the feature/order-state-placed branch June 5, 2018 23:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants