File tree Expand file tree Collapse file tree 4 files changed +53
-10
lines changed
src/main/java/io/serverlessworkflow/impl Expand file tree Collapse file tree 4 files changed +53
-10
lines changed Original file line number Diff line number Diff line change 2121 <artifactId >slf4j-api</artifactId >
2222 </dependency >
2323 <dependency >
24- <groupId >com.github.f4b6a3 </groupId >
25- <artifactId >ulid-creator </artifactId >
24+ <groupId >de.huxhorn.sulky </groupId >
25+ <artifactId >de.huxhorn.sulky. ulid</artifactId >
2626 </dependency >
2727 </dependencies >
2828</project >
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2020-Present The Serverless Workflow Specification Authors
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ package io .serverlessworkflow .impl ;
17+
18+ import de .huxhorn .sulky .ulid .ULID ;
19+ import java .security .SecureRandom ;
20+ import java .util .concurrent .atomic .AtomicReference ;
21+
22+ /**
23+ * A {@link WorkflowInstanceIdFactory} implementation that generates Monotonic ULIDs as workflow
24+ * instance IDs.
25+ */
26+ public class MonotonicUlidWorkflowInstanceIdFactory implements WorkflowInstanceIdFactory {
27+
28+ private final ULID ulid ;
29+ private final AtomicReference <ULID .Value > currentUlid ;
30+
31+ public MonotonicUlidWorkflowInstanceIdFactory () {
32+ this .ulid = new ULID (new SecureRandom ());
33+ this .currentUlid = new AtomicReference <>(ulid .nextValue ());
34+ }
35+
36+ public String get () {
37+ return currentUlid
38+ .getAndUpdate (previousUlid -> ulid .nextMonotonicValue (previousUlid ))
39+ .toString ();
40+ }
41+ }
Original file line number Diff line number Diff line change 1515 */
1616package io .serverlessworkflow .impl ;
1717
18- import com .github .f4b6a3 .ulid .UlidCreator ;
1918import io .serverlessworkflow .api .types .SchemaInline ;
2019import io .serverlessworkflow .api .types .Workflow ;
2120import io .serverlessworkflow .impl .events .EventConsumer ;
@@ -141,7 +140,7 @@ public SchemaValidator getValidator(SchemaInline inline) {
141140 private ResourceLoaderFactory resourceLoaderFactory = DefaultResourceLoaderFactory .get ();
142141 private SchemaValidatorFactory schemaValidatorFactory ;
143142 private WorkflowPositionFactory positionFactory = () -> new QueueWorkflowPosition ();
144- private WorkflowInstanceIdFactory idFactory = () -> UlidCreator . getMonotonicUlid (). toString () ;
143+ private WorkflowInstanceIdFactory idFactory ;
145144 private ExecutorServiceFactory executorFactory = new DefaultExecutorServiceFactory ();
146145 private EventConsumer <?, ?> eventConsumer ;
147146 private Collection <EventPublisher > eventPublishers = new ArrayList <>();
@@ -244,6 +243,9 @@ public WorkflowApplication build() {
244243 return inMemory ;
245244 });
246245 }
246+ if (idFactory == null ) {
247+ idFactory = new MonotonicUlidWorkflowInstanceIdFactory ();
248+ }
247249 return new WorkflowApplication (this );
248250 }
249251 }
Original file line number Diff line number Diff line change 99 <name >Serverless Workflow :: Impl</name >
1010 <packaging >pom</packaging >
1111 <properties >
12- <version .org.glassfish.jersey>3.1.11</version .org.glassfish.jersey>
13- <version .net.thisptr>1.6.0</version .net.thisptr>
14- <version .com.github.f4b6a3>5.2.3</version .com.github.f4b6a3>
12+ <version .de.huxhorn.sulky>8.3.0</version .de.huxhorn.sulky>
1513 <version .jakarta.ws.rs>4.0.0</version .jakarta.ws.rs>
14+ <version .net.thisptr>1.6.0</version .net.thisptr>
15+ <version .org.glassfish.jersey>3.1.11</version .org.glassfish.jersey>
1616 </properties >
1717 <dependencyManagement >
1818 <dependencies >
4242 <version >${version.net.thisptr} </version >
4343 </dependency >
4444 <dependency >
45- <groupId >com.github.f4b6a3 </groupId >
46- <artifactId >ulid-creator </artifactId >
47- <version >${version.com.github.f4b6a3 } </version >
45+ <groupId >de.huxhorn.sulky </groupId >
46+ <artifactId >de.huxhorn.sulky. ulid</artifactId >
47+ <version >${version.de.huxhorn.sulky } </version >
4848 </dependency >
4949 <dependency >
5050 <groupId >jakarta.ws.rs</groupId >
You can’t perform that action at this time.
0 commit comments