clszzyh / flexflow

Lightweight and flexible workflow engine.

Home Page:https://clszzyh.github.io/flexflow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flexflow

ci Hex.pm Hex.pm Documentation Last Updated Lines of code

Usage

defmodule Review do
  @vsn "1.0.1"
  use Flexflow.Process

  defmodule Reviewing do
    use Flexflow.State
  end

  defmodule Submit do
    use Flexflow.Event
  end

  ## Start state
  state {Start, :draft}
  state {End, :reviewed}
  state {End, :canceled}
  ## Bypass state
  state :rejected
  ## Custom state
  state Reviewing

  ## Define a event
  ## `a ~> b` is a shortcut of `{a, b}`
  event :modify1, :draft ~> :draft
  event :cancel1, :draft ~> :canceled, results: [:foo]

  ## Custom event
  event Submit, :draft ~> Reviewing

  event :modify2, :rejected ~> :rejected
  event :cancel2, :rejected ~> :canceled, results: [:foo]

  ## With custom name
  event {Submit, :submit2}, :rejected ~> Reviewing

  event :reject, Reviewing ~> :rejected
  event :agree, Reviewing ~> :reviewed, results: [:foo]
end

Graphviz Dot

// review_mark
digraph review {
  size ="4,4";
  draft [label="draft",shape=doublecircle,color=".7 .3 1.0"];
  reviewed [label="reviewed",style=bold,shape=circle,color=red];
  canceled [label="canceled",shape=circle,color=red];
  rejected [label="rejected",shape=box];
  reviewing [label="reviewing",shape=box];
  draft -> draft [label="modify1"];
  draft -> canceled [label="cancel1"];
  draft -> reviewing [label="submit_draft"];
  rejected -> rejected [label="modify2"];
  rejected -> canceled [label="cancel2"];
  rejected -> reviewing [label="submit2"];
  reviewing -> rejected [label="reject"];
  reviewing -> reviewed [label="agree"];
}
// review_mark

TODO

  1. Support :gen_statem
State(S) x Event(E) -> Actions(A), State(S')

See also

About

Lightweight and flexible workflow engine.

https://clszzyh.github.io/flexflow

License:MIT License


Languages

Language:Elixir 100.0%