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 21
21
<artifactId >slf4j-api</artifactId >
22
22
</dependency >
23
23
<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 >
26
26
</dependency >
27
27
</dependencies >
28
28
</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 15
15
*/
16
16
package io .serverlessworkflow .impl ;
17
17
18
- import com .github .f4b6a3 .ulid .UlidCreator ;
19
18
import io .serverlessworkflow .api .types .SchemaInline ;
20
19
import io .serverlessworkflow .api .types .Workflow ;
21
20
import io .serverlessworkflow .impl .events .EventConsumer ;
@@ -141,7 +140,7 @@ public SchemaValidator getValidator(SchemaInline inline) {
141
140
private ResourceLoaderFactory resourceLoaderFactory = DefaultResourceLoaderFactory .get ();
142
141
private SchemaValidatorFactory schemaValidatorFactory ;
143
142
private WorkflowPositionFactory positionFactory = () -> new QueueWorkflowPosition ();
144
- private WorkflowInstanceIdFactory idFactory = () -> UlidCreator . getMonotonicUlid (). toString () ;
143
+ private WorkflowInstanceIdFactory idFactory ;
145
144
private ExecutorServiceFactory executorFactory = new DefaultExecutorServiceFactory ();
146
145
private EventConsumer <?, ?> eventConsumer ;
147
146
private Collection <EventPublisher > eventPublishers = new ArrayList <>();
@@ -244,6 +243,9 @@ public WorkflowApplication build() {
244
243
return inMemory ;
245
244
});
246
245
}
246
+ if (idFactory == null ) {
247
+ idFactory = new MonotonicUlidWorkflowInstanceIdFactory ();
248
+ }
247
249
return new WorkflowApplication (this );
248
250
}
249
251
}
Original file line number Diff line number Diff line change 9
9
<name >Serverless Workflow :: Impl</name >
10
10
<packaging >pom</packaging >
11
11
<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>
15
13
<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>
16
16
</properties >
17
17
<dependencyManagement >
18
18
<dependencies >
42
42
<version >${version.net.thisptr} </version >
43
43
</dependency >
44
44
<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 >
48
48
</dependency >
49
49
<dependency >
50
50
<groupId >jakarta.ws.rs</groupId >
You can’t perform that action at this time.
0 commit comments