Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/josh-mchugh/quarkus-state-machine
Project to learn and apply a simple state machine pattern
https://github.com/josh-mchugh/quarkus-state-machine
java quarkus
Last synced: 21 days ago
JSON representation
Project to learn and apply a simple state machine pattern
- Host: GitHub
- URL: https://github.com/josh-mchugh/quarkus-state-machine
- Owner: josh-mchugh
- Created: 2023-01-09T02:54:02.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-30T03:38:40.000Z (almost 2 years ago)
- Last Synced: 2024-11-11T21:33:16.168Z (3 months ago)
- Topics: java, quarkus
- Language: Java
- Homepage:
- Size: 800 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![build](https://github.com/josh-mchugh/quarkus-state-machine/actions/workflows/main.yml/badge.svg)
[![codecov](https://codecov.io/gh/josh-mchugh/quarkus-state-machine/branch/main/graph/badge.svg?token=7E1TWYKBSF)](https://codecov.io/gh/josh-mchugh/quarkus-state-machine)# Simple Statemachine With Quarkus
This project is an experiment for designing a simple statemachine. I have used more complex statemachines such as [Spring Statemachine](https://spring.io/projects/spring-statemachine). I wanted to make a simple Java based statemachine pattern without the use of a framework. I used Quarkus as a RESTful API framework for demostration and practice purposes.
I based it off an article from Baeldung: [https://www.baeldung.com/java-enum-simple-state-machine](https://www.baeldung.com/java-enum-simple-state-machine)
Instead of using the LeaveRequestState for manging approval states of somones leave. I decided to make a small statemachine around Git pull requests.
## State Diagram
There are a total of 4 states within this state machine.
1. DRAFT
2. OPEN
3. MERGED
4. CLOSEDDRAFT is the starting state.
MERGED and closed are end states.DRAFT can transition to OPEN
OPEN can transition to MERGED or CLOSED
CLOSE can transition to OPEN![Diagram of the states and their transitions for the state machine](./images/state-diagram.png)
## Demostration
An example of a successful flow of creating a pull request and transitioning it to the merge state
![Example of successful state transitions](./images/quarkus-state-machine-successful-example.gif)
An example of an unsuccessful flow is creating a pull request and attempting to transition between states in an incorrect order
![Example of unsuccessful state transitions](./images/quarkus-state-machine-unsuccessful-example.gif)
## Running the application in dev mode
You can run your application in dev mode that enables live coding using:
```shell script
./mvnw compile quarkus:dev
```