Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DT-2502 - handle WorkflowExecutionUpdateAdmitted events #2364

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
7 changes: 3 additions & 4 deletions src/lib/models/event-groups/create-event-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,13 @@ const createGroupFor = <K extends keyof StartingEvents>(
events?: CommonHistoryEvent[],
): EventGroup => {
const id = getGroupId(event);
const name = getEventGroupName(event);
const initialEvent = getInitialEvent(event, events);
const name = getEventGroupName(event, initialEvent);
const label = getEventGroupLabel(event);
const displayName = getEventGroupDisplayName(event);
const displayName = getEventGroupDisplayName(event, initialEvent);

const { timestamp, category, classification } = event;

const initialEvent = getInitialEvent(event, events);

const groupEvents: EventGroup['events'] = new Map();
const groupEventIds: EventGroup['eventIds'] = new Set();

Expand Down
22 changes: 17 additions & 5 deletions src/lib/models/event-groups/get-group-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ import {
isTimerStartedEvent,
isWorkflowExecutionSignaledEvent,
isWorkflowExecutionUpdateAcceptedEvent,
isWorkflowExecutionUpdateAdmittedEvent,
} from '$lib/utilities/is-event-type';

export const getEventGroupName = (event: CommonHistoryEvent): string => {
export const getEventGroupName = (
event: CommonHistoryEvent,
initialEvent?: CommonHistoryEvent,
): string => {
if (!event) return '';

if (isActivityTaskScheduledEvent(event)) {
Expand Down Expand Up @@ -50,8 +54,13 @@ export const getEventGroupName = (event: CommonHistoryEvent): string => {
}

if (isWorkflowExecutionUpdateAcceptedEvent(event)) {
return event.workflowExecutionUpdateAcceptedEventAttributes?.acceptedRequest
?.input?.name;
if (isWorkflowExecutionUpdateAdmittedEvent(initialEvent)) {
return initialEvent.workflowExecutionUpdateAdmittedEventAttributes
?.request?.input?.name;
} else {
return event.workflowExecutionUpdateAcceptedEventAttributes
?.acceptedRequest?.input?.name;
}
}

if (isNexusOperationScheduledEvent(event)) {
Expand Down Expand Up @@ -102,12 +111,15 @@ export const getEventGroupLabel = (event: CommonHistoryEvent): string => {
}
};

export const getEventGroupDisplayName = (event: CommonHistoryEvent): string => {
export const getEventGroupDisplayName = (
event: CommonHistoryEvent,
initialEvent?: CommonHistoryEvent,
): string => {
if (!event) return '';

if (isLocalActivityMarkerEvent(event)) {
return getSummaryAttribute(event)?.value?.toString() ?? 'Local Activity';
}

return getEventGroupName(event);
return getEventGroupName(event, initialEvent);
};
2 changes: 2 additions & 0 deletions src/lib/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ export type ExternalWorkflowExecutionSignaledEvent =
EventWithAttributes<'externalWorkflowExecutionSignaledEventAttributes'>;
export type UpsertWorkflowSearchAttributesEvent =
EventWithAttributes<'upsertWorkflowSearchAttributesEventAttributes'>;
export type WorkflowExecutionUpdateAdmittedEvent =
EventWithAttributes<'workflowExecutionUpdateAdmittedEventAttributes'>;
export type WorkflowExecutionUpdateAcceptedEvent =
EventWithAttributes<'workflowExecutionUpdateAcceptedEventAttributes'>;
export type WorkflowExecutionUpdateCompletedEvent =
Expand Down
7 changes: 7 additions & 0 deletions src/lib/utilities/is-event-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import type {
WorkflowExecutionTerminatedEvent,
WorkflowExecutionTimedOutEvent,
WorkflowExecutionUpdateAcceptedEvent,
WorkflowExecutionUpdateAdmittedEvent,
WorkflowExecutionUpdateCompletedEvent,
WorkflowTaskCompletedEvent,
WorkflowTaskFailedEvent,
Expand Down Expand Up @@ -162,6 +163,7 @@ export const eventAttributeKeys: Readonly<EventAttributeKey[]> = [
'markerRecordedEventAttributes',
'workflowExecutionSignaledEventAttributes',
'workflowExecutionTerminatedEventAttributes',
'workflowExecutionUpdateAdmittedEventAttributes',
'workflowExecutionUpdateAcceptedEventAttributes',
'workflowExecutionUpdateCompletedEventAttributes',
'workflowExecutionUpdateRejectedEventAttributes',
Expand Down Expand Up @@ -453,6 +455,11 @@ export const isWorkflowExecutionUpdateAcceptedEvent =
'workflowExecutionUpdateAcceptedEventAttributes',
);

export const isWorkflowExecutionUpdateAdmittedEvent =
hasAttributes<WorkflowExecutionUpdateAdmittedEvent>(
'workflowExecutionUpdateAdmittedEventAttributes',
);

export const isWorkflowExecutionUpdateCompletedEvent =
hasAttributes<WorkflowExecutionUpdateCompletedEvent>(
'workflowExecutionUpdateCompletedEventAttributes',
Expand Down
Loading