Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Nieder mit dem Spaghetti Code durch Statemachines
Search
Nicolas Byl
April 25, 2018
Technology
0
93
Nieder mit dem Spaghetti Code durch Statemachines
Nicolas Byl
April 25, 2018
Tweet
Share
More Decks by Nicolas Byl
See All by Nicolas Byl
Die Flucht aus der Prototypen-Hölle
nbyl
0
8
Lean Prototyping for Industrial-IoT Projects
nbyl
0
16
DevSecOps - Vom Unikum zur gut geölten Maschine
nbyl
0
65
Securing your software supply chain
nbyl
0
240
Keeping-Up-WithUpstream.pdf
nbyl
0
88
Dr. Kube und der Helm - Anatomie einer CD-Pipeline
nbyl
0
82
Securing the "other" supply chain
nbyl
0
200
Kubernetes - Auf die Cluster, Fertig, Los!
nbyl
0
110
Helm - Kubernetes Deployments richtig gemacht
nbyl
0
89
Other Decks in Technology
See All in Technology
CI/CDがあたりまえの今の時代にAPIテスティングツールに求められていること / CI/CD Test Night #7
k1low
12
3.1k
OpenTelemetry実践 はじめの一歩
taxin
0
330
バッチ処理のSLOをどう設計するか
rynsuke
7
590
中央集権体制からDataOpsへの転換 / centralized-to-dataops-transformation
pei0804
7
1.6k
期待しすぎずに取り組む両面 TypeScript
shozawa
4
540
Why do you get AWS certificates
hirosys
0
120
GraphQLに入門してみた
chiroruxx
2
130
技術広報として2023年度に頑張ったこと / What we did well in FY2023 as a DevRel
pauli
5
490
LLMプロダクト事業の立ち上げにおける挑戦
layerx
PRO
7
1.5k
どう買う?Azure
kuniteru
1
190
エバンジェリスト活動を7年やってきて見えてきた、コミュニティとエバンジェリストの関係
soracom
PRO
1
200
コードレビューを支援するAI技術の応用
akkie76
2
170
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
72
8.2k
Writing Fast Ruby
sferik
619
59k
Intergalactic Javascript Robots from Outer Space
tanoku
266
26k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
355
22k
Fantastic passwords and where to find them - at NoRuKo
philnash
35
2.4k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
18
6.8k
From Idea to $5000 a Month in 5 Months
shpigford
376
45k
Making the Leap to Tech Lead
cromwellryan
123
8.4k
Designing the Hi-DPI Web
ddemaree
275
33k
The Power of CSS Pseudo Elements
geoffreycrofte
58
4.9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
272
12k
Building Your Own Lightsaber
phodgson
97
5.6k
Transcript
1 NIEDER MIT DEM SPAGHETTI CODE DURCH STATEMACHINES JAX 2018
Nicolas Byl, codecentric AG
2 . 1 EINLEITUNG
None
2 . 2
2 . 3 2 . 4 Wer hat bereits eine
State Machine implementiert?
if (order.getState() == State.COMMISSIONED) { order.setState(State.SHIPPED); order.save(); }
2 . 5 2 . 6 Nochmal: Wer hat bereits
eine State Machine implementiert?
3 . 1 STATE MACHINES
3 . 2 Ein Beispiel Downloading docker pull Blocked docker
create Image is pulled Dependencies satisfied Pending Starting docker start Ready Throttling policy LivenessProbe reports its first OK Failed Time-out
3 . 3 Zustandsänderungen
3 . 4 DISTRIBUTED BALL OF MUD https://commons.wikimedia.org/wiki/File:Taylor%27s_Dorodango_cropped.jpg
3 . 5 Zustandsänderungen konzentrieren
4 . 1 SPRING STATE MACHINES
4 . 2 Spring State Machines State Machine Library Spring
Integration Event-basiert
4 . 3 Integration <dependencies> <dependency> <groupId>org.springframework.statemachine</groupId> <artifactId>spring-statemachine-core</artifactId> <version>1.2.8.RELEASE</version> </dependency>
</dependencies>
4 . 4 Konfiguration @Configuration @EnableStateMachine public class StateMachineConfig extends
EnumStateMachineConfigurerAda @Override public void configure(StateMachineStateConfigurer<CheckStatus, Ch states .withStates() .initial(CheckStatus.Initializing) .states(EnumSet.allOf(CheckStatus.class)); }
4 . 5 Konfiguration (2) @Override public void configure(StateMachineTransitionConfigurer<CheckStatu transitions
.withExternal() .source(CheckStatus.Initializing).target(CheckStatus. .and() .withExternal() .source(CheckStatus.Initializing).target(CheckStatus. .and() [...]; } }
4 . 6 Events auslösen stateMachine.sendEvent(CheckEvents.succeeded);
4 . 7 Zustandsänderungen überwachen @WithStateMachine static class MyBean {
@OnTransition(target = CheckStatus.Operational) void enteredOperational() { } @OnStateChanged public void checkStatusChanged(StateContext<CheckStatus, CheckEve } }
5 . 1 DEMO TIME
5 . 2 Monitoring Demo Monitoring von lokalen Dateien Alarmierung
wenn zwei Checks in Folge fehlschlagen
5 . 3 State Machine
5 . 4 Demo Project https://github.com/nbyl/spring-state-machine-demo
6 . 1 SPRING STATE MACHINE
6 . 2 Advanced Features Verteilte State Machines mittels Zookeeper
Scoping Security State Persistence
7 . 1 THE END Copyright 2018