Giter Club home page Giter Club logo

go-fsm-order's Introduction

订单流程图

订单流转图

基于上述订单流转流程,使用有限状态机的方式用 Golang 代码进行实现。

运行结果

正在处理创建订单逻辑,订单ID(1), 订单名称(测试订单) ... 处理完毕!
发送短信,给(18888888888)发送了(恭喜你预定成功了!)
操作[创建订单],状态从 [默认] 变成 [已预订]
[警告] 状态(已预订)不允许操作(修改订单)
操作[确定订单],状态从 [已预订] 变成 [已确认]
操作[修改订单],状态从 [已确认] 变成 [已预订]
操作[确定订单],状态从 [已预订] 变成 [已确认]
操作[支付订单],状态从 [已确认] 变成 [已锁定]

有限状态机

简介

有限状态机(Finite-state machine,简写:FSM)又可以称作有限状态自动机,简称状态机。

它必须是可以附着在某种事物上的,且该事物的状态是有限的,通过某些触发事件,会让其状态发生转换。为此,有限状态机就是描述这些有限的状态和触发事件及转换行为的数学模型。

PS:关于状态机的简介可以去网上搜索,以上供参考。

特性

  • 状态总数(state)是有限的。
  • 任一时刻,只处在一种状态之中。
  • 某种条件下,会从一种状态转变(transition)到另一种状态。

联系作者

联系作者

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.