mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(sfn): no execution data available via SDK (#1506)
* fix(1504): fix execution history handling * fix(1504): add tests * fix(1504): add negative test * chore(sfn): pr comments
This commit is contained in:
1 parent
2288454021
commit
e5a646d40c
4 files changed
+280
-3
No files matched your search
+16
-3
@@ -212,7 +212,10 @@ public class StepFunctionsJsonHandler {
|
||||
}
|
||||
|
||||
private Response handleGetExecutionHistory(JsonNode request) {
|
||||
List<HistoryEvent> events = service.getExecutionHistory(request.path("executionArn").asText());
|
||||
var arn = request.path("executionArn").asText();
|
||||
var includeExecutionData = request.path("includeExecutionData").asBoolean(true);
|
||||
|
||||
List<HistoryEvent> events = service.getExecutionHistory(arn);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ArrayNode array = response.putArray("events");
|
||||
for (HistoryEvent e : events) {
|
||||
@@ -221,13 +224,23 @@ public class StepFunctionsJsonHandler {
|
||||
item.put("timestamp", e.getTimestamp());
|
||||
item.put("type", e.getType());
|
||||
if (e.getPreviousEventId() != null) item.put("previousEventId", e.getPreviousEventId());
|
||||
if (e.getDetails() != null) {
|
||||
item.set(e.getType() + "EventDetails", objectMapper.valueToTree(e.getDetails()));
|
||||
if (includeExecutionData && e.getDetails() != null) {
|
||||
item.set(historyEventDetailsField(e.getType()), objectMapper.valueToTree(e.getDetails()));
|
||||
}
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
static String historyEventDetailsField(String type) {
|
||||
if (type.endsWith("StateEntered")) {
|
||||
return "stateEnteredEventDetails";
|
||||
}
|
||||
if (type.endsWith("StateExited")) {
|
||||
return "stateExitedEventDetails";
|
||||
}
|
||||
return Character.toLowerCase(type.charAt(0)) + type.substring(1) + "EventDetails";
|
||||
}
|
||||
|
||||
private Response handleSendTaskSuccess(JsonNode request) {
|
||||
service.sendTaskSuccess(request.path("taskToken").asText(), request.path("output").asText());
|
||||
return Response.ok(objectMapper.createObjectNode()).build();
|
||||
|
||||
Reference in new issue
Block a user