Skip to content

Commit

Permalink
Merge pull request #244 from orkes-io/idempotency
Browse files Browse the repository at this point in the history
Workflow idempotency changes.
  • Loading branch information
manan164 authored Nov 29, 2023
2 parents 1bfb797 + ed635dc commit 4f72063
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright 2020 Netflix, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 com.netflix.conductor.common.metadata.workflow;

public enum IdempotencyStrategy {
FAIL,
RETURN_EXISTING
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ public class StartWorkflowRequest {
@ProtoField(id = 9)
private String createdBy;

private String idempotencyKey;

private IdempotencyStrategy idempotencyStrategy;

public String getIdempotencyKey() {
return idempotencyKey;
}

public void setIdempotencyKey(String idempotencyKey) {
this.idempotencyKey = idempotencyKey;
}

public IdempotencyStrategy getIdempotencyStrategy() {
return idempotencyStrategy;
}

public void setIdempotencyStrategy(IdempotencyStrategy idempotencyStrategy) {
this.idempotencyStrategy = idempotencyStrategy;
}

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ public boolean isSuccessful() {
@ProtoField(id = 25)
private List<Workflow> history = new LinkedList<>();

private String idempotencyKey;

public String getIdempotencyKey() {
return idempotencyKey;
}

public void setIdempotencyKey(String idempotencyKey) {
this.idempotencyKey = idempotencyKey;
}

public List<Workflow> getHistory() {
return history;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package com.netflix.conductor.common.validation;

import java.util.List;
import java.util.Map;

public class ErrorResponse {

Expand All @@ -23,6 +24,16 @@ public class ErrorResponse {
private boolean retryable;
private List<ValidationError> validationErrors;

private Map<String, Object> metadata;

public Map<String, Object> getMetadata() {
return metadata;
}

public void setMetadata(Map<String, Object> metadata) {
this.metadata = metadata;
}

public int getStatus() {
return status;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ public int getStatusCode() {
}
}

public Map<String, Object> getMetadata() {
return metadata;
}

public void setMetadata(Map<String, Object> metadata) {
this.metadata = metadata;
}

private Map<String, Object> metadata;

private final Code code;

public boolean isRetryable() {
Expand All @@ -64,6 +74,12 @@ public ApplicationException(Code code, String message) {
this.code = code;
}

public ApplicationException(Code code, String message, Map<String, Object> metadata) {
super(message);
this.code = code;
this.metadata = metadata;
}

public int getHttpStatusCode() {
return this.code.getStatusCode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public boolean isSuccessful() {
private String failedTaskId;

private Status previousStatus;
private String idempotencyKey;

private List<WorkflowModel> history = new LinkedList<>();

Expand Down Expand Up @@ -449,6 +450,14 @@ public TaskModel getTaskByRefName(String refName) {
return found.getLast();
}

public String getIdempotencyKey() {
return idempotencyKey;
}

public void setIdempotencyKey(String idempotencyKey) {
this.idempotencyKey = idempotencyKey;
}

public void externalizeInput(String path) {
this.inputPayload = this.input;
this.input = new HashMap<>();
Expand Down

0 comments on commit 4f72063

Please sign in to comment.