-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathOrchestrationHistoryEvent.java
More file actions
95 lines (87 loc) · 2.97 KB
/
OrchestrationHistoryEvent.java
File metadata and controls
95 lines (87 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.microsoft.durabletask;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.time.Instant;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Transport-neutral representation of a single orchestration history event.
* <p>
* This type decouples the public SDK API from the underlying gRPC/protobuf transport types,
* ensuring API stability even if the wire format evolves. It is returned by
* {@link DurableTaskClient#getOrchestrationHistory(String)}.
*/
public final class OrchestrationHistoryEvent {
private final int eventId;
private final Instant timestamp;
private final String eventType;
private final Map<String, Object> data;
/**
* Creates a new {@code OrchestrationHistoryEvent}.
*
* @param eventId the sequence ID of the event within the orchestration history
* @param timestamp the UTC timestamp when the event was recorded
* @param eventType the type name of the event (e.g., "ExecutionStarted", "TaskScheduled")
* @param data the event-specific data fields, or an empty map if none
*/
public OrchestrationHistoryEvent(
int eventId,
@Nonnull Instant timestamp,
@Nonnull String eventType,
@Nonnull Map<String, Object> data) {
if (timestamp == null) {
throw new IllegalArgumentException("timestamp must not be null.");
}
if (eventType == null || eventType.isEmpty()) {
throw new IllegalArgumentException("eventType must not be null or empty.");
}
if (data == null) {
throw new IllegalArgumentException("data must not be null.");
}
this.eventId = eventId;
this.timestamp = timestamp;
this.eventType = eventType;
this.data = Collections.unmodifiableMap(new HashMap<>(data));
}
/**
* Gets the sequence ID of this event within the orchestration history.
*
* @return the event ID
*/
public int getEventId() {
return this.eventId;
}
/**
* Gets the UTC timestamp when this event was recorded.
*
* @return the event timestamp
*/
@Nonnull
public Instant getTimestamp() {
return this.timestamp;
}
/**
* Gets the type name of this event (e.g., "ExecutionStarted", "TaskScheduled", "TaskCompleted").
*
* @return the event type name
*/
@Nonnull
public String getEventType() {
return this.eventType;
}
/**
* Gets the event-specific data fields as an unmodifiable map.
* <p>
* The keys and structure of this map depend on the event type. For example, an
* "ExecutionStarted" event may contain "name", "input", and "version" fields.
*
* @return unmodifiable map of event data
*/
@Nonnull
public Map<String, Object> getData() {
return this.data;
}
}