Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions impl/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.github.f4b6a3</groupId>
<artifactId>ulid-creator</artifactId>
<groupId>de.huxhorn.sulky</groupId>
<artifactId>de.huxhorn.sulky.ulid</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2020-Present The Serverless Workflow Specification Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.serverlessworkflow.impl;

import de.huxhorn.sulky.ulid.ULID;
import java.security.SecureRandom;
import java.util.concurrent.atomic.AtomicReference;

/**
* A {@link WorkflowInstanceIdFactory} implementation that generates Monotonic ULIDs as workflow
* instance IDs.
*/
public class MonotonicUlidWorkflowInstanceIdFactory implements WorkflowInstanceIdFactory {

private final ULID ulid;
private final AtomicReference<ULID.Value> currentUlid;

public MonotonicUlidWorkflowInstanceIdFactory() {
this.ulid = new ULID(new SecureRandom());
this.currentUlid = new AtomicReference<>(ulid.nextValue());
}

public String get() {
return currentUlid
.getAndUpdate(previousUlid -> ulid.nextMonotonicValue(previousUlid))
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package io.serverlessworkflow.impl;

import com.github.f4b6a3.ulid.UlidCreator;
import io.serverlessworkflow.api.types.SchemaInline;
import io.serverlessworkflow.api.types.Workflow;
import io.serverlessworkflow.impl.events.EventConsumer;
Expand Down Expand Up @@ -141,7 +140,7 @@ public SchemaValidator getValidator(SchemaInline inline) {
private ResourceLoaderFactory resourceLoaderFactory = DefaultResourceLoaderFactory.get();
private SchemaValidatorFactory schemaValidatorFactory;
private WorkflowPositionFactory positionFactory = () -> new QueueWorkflowPosition();
private WorkflowInstanceIdFactory idFactory = () -> UlidCreator.getMonotonicUlid().toString();
private WorkflowInstanceIdFactory idFactory;
private ExecutorServiceFactory executorFactory = new DefaultExecutorServiceFactory();
private EventConsumer<?, ?> eventConsumer;
private Collection<EventPublisher> eventPublishers = new ArrayList<>();
Expand Down Expand Up @@ -244,6 +243,9 @@ public WorkflowApplication build() {
return inMemory;
});
}
if (idFactory == null) {
idFactory = new MonotonicUlidWorkflowInstanceIdFactory();
}
return new WorkflowApplication(this);
}
}
Expand Down
12 changes: 6 additions & 6 deletions impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<name>Serverless Workflow :: Impl</name>
<packaging>pom</packaging>
<properties>
<version.org.glassfish.jersey>3.1.11</version.org.glassfish.jersey>
<version.net.thisptr>1.6.0</version.net.thisptr>
<version.com.github.f4b6a3>5.2.3</version.com.github.f4b6a3>
<version.de.huxhorn.sulky>8.3.0</version.de.huxhorn.sulky>
<version.jakarta.ws.rs>4.0.0</version.jakarta.ws.rs>
<version.net.thisptr>1.6.0</version.net.thisptr>
<version.org.glassfish.jersey>3.1.11</version.org.glassfish.jersey>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -42,9 +42,9 @@
<version>${version.net.thisptr}</version>
</dependency>
<dependency>
<groupId>com.github.f4b6a3</groupId>
<artifactId>ulid-creator</artifactId>
<version>${version.com.github.f4b6a3}</version>
<groupId>de.huxhorn.sulky</groupId>
<artifactId>de.huxhorn.sulky.ulid</artifactId>
<version>${version.de.huxhorn.sulky}</version>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
Expand Down