Comments (4)
Isn't the maximum size of a "group" 2? So it's not really that much extra processing - the finds are constant time
from eventual.
The code is matching activities right now, but don't see why it can't be broadened to match any schedule/end event, using the same heuristic style as your sampel code. While I do generally like more declarative code, I think in this case doing the grouping / find thing results in a lot of extra processing, doing a bunch of passes over nested lists. It can just be done in one pass by building the output map as you go:
let spanningActivities = Record<seq, TimelineActivity>{}
const otherActivities = TimelineActivity[]
events.forEach((event) => {
if (match(event, isWorkflowStarted)) {
start = event;
} else if (match(event, isScheduledEvent)) {
//creates timelineactivity with start time and event type
spanningActivities[event.seq] = {type: activityType(event.type), start: event.start}
} else if (match(event, or(isCompletedEvent, isFailedEvent, isWorkflowTimedOut)) {
//update timelineactivity with state and end time
spanningActivities[event.seq].state = {status: activityStatus(event), end: event.end}
} else if (event.match(or(isSignalReceived, isWorkflowStarted, isWorkflowFailed, isWorkflowCompleted, isWorkflowTimedOut)) {
otherActivities.push(activityOf(event))
}
}
return [...Object.entries(spanningActivities), ...otherActivities]
As far as I can tell the outcome is the same, just a bit lower level, a bit more verbose, but saving a bunch of computation.
from eventual.
After grouping, the nested lists should be small, I doubt you'd be able to come up with a realistic history where you'd tell the performance difference. The groupby is doing most of the work here.
Clean/correct code > micro-optimizations. Then optimize if there is an actual issue.
Your implementation:
- relies on the order
- will always take the last event that matches the condition (mine takes the first)
- depends on both events existing in order (not fault tolerant)
- doesn't filter out the start or end event from "other"
- ignores the non-state/end events that may relate to an "Eventual"/activity.
If your stateful accumulator can resolve this issues (with more code), then I think it would be fine, but... correct > micro-optimized.
from eventual.
Maybe not max (ex: we may get a "timeout" and then later get the "complete") or we may have intra-activity events in the future like a heartbeat checkpoint that gets stored in the workflow.
Though I'd constrain the size of a group to an average of < magnitude 10. (aka essentially constant).
from eventual.
Related Issues (20)
- Secret Support
- ECS-backed Task
- Bug: Some Errors don't normalize correctly
- Local: Support Logs CLI command
- Bug(local): Errors in handlers crash the server
- Entity Streams don't log errors
- Feat: Transactions should be able to run inline in handlers HOT 4
- Local not restoring Set data type in Entity HOT 1
- Local server not exiting on Ctrl+C
- Local crashes when restoring: "connection doesn't exist" for web sockets HOT 1
- Local numeric sort key does not deserialize properly
- Seamless integration with Frontend Frameworks
- [Local] Compute missing local entity indices on load for existing data
- Configure Compliance Controls
- We should list the names of the services when `eventual get service` errors
- Fix dependabot issues
- Feat: Add abort signal to client
- Workflow stuck when task execution crashes
- Entity attributes do not support z.custom()
- tsbuildinfo cache files are published to npm HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eventual.