Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js with a statemachine

I understand that node.js is a single thread and is a single process in the memory, I'm working on a project employing state machine and wondering how that will work in this context. I'm feeling the states will be shared across users because it's a single thread or a single process. Calling out for directions/advices.

let's say I've state A, state B, state C

Application can only transition in this sequence, A -> B -> C

Initial state is A,

user 1 requests and as a result the state machine moves to state B and then finally state C

user 2 requests, will the state machine for this new user be in state A or state C?

like image 940
user2727195 Avatar asked Oct 16 '14 05:10

user2727195


1 Answers

This article has a very interesting approach on how to deal with the FSM abstraction under an event based environment.

http://www.robert-drummond.com/2015/04/21/event-driven-programming-finite-state-machines-and-nodejs/

See also:

  • https://gist.github.com/podefr/1312642
  • http://machina-js.org/
  • https://github.com/fschaefer/Stately.js/
  • https://github.com/jakesgordon/javascript-state-machine
like image 131
Henry H. Avatar answered Sep 19 '22 17:09

Henry H.