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

Support merging #43

Merged
merged 17 commits into from
Mar 11, 2024
Merged

Support merging #43

merged 17 commits into from
Mar 11, 2024

Conversation

hansSchall
Copy link
Contributor

fixes #2

@hansSchall
Copy link
Contributor Author

This overlay for Receiver will store the latest values for all sources for the specified time.
When any source changes, the merged values will be recomputed and changes within the output will be delivered to the user, by using the changed event.

Usage:

const rec = new ReceiverMerge({
    universes: [1],
    reuseAddr: true,
    timeout: 5000, // time the values will be stored before they are droped (assuming the source is down / has stopped sending data)
    // ... more options (everything here will be passed to new Receiver({...}))
})

rec.on("changed", ({ addr, newValue: value }) => { console.log(addr, value) });

Copy link
Owner

@k-yle k-yle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks! I'll have some time next week to properly test it.

src/merge.ts Outdated Show resolved Hide resolved
src/merge.ts Outdated Show resolved Hide resolved
src/merge.ts Outdated Show resolved Hide resolved
hansSchall and others added 5 commits April 8, 2022 12:40
add sender connect event

Co-authored-by: Kyℓe Hensel <[email protected]>
clean up constructor

Co-authored-by: Kyℓe Hensel <[email protected]>
add default value 0
- more detailed senderConnect
- more detailed senderDisconnect
- convert ServersData to interface
@hansSchall
Copy link
Contributor Author

I have coded more detailed event objects; now they contain the senders cid and universe

API

merger.on("senderConnect", (ev: {cid: string, universe: number, firstPacket: Packet}) => {
  ...
});
merger.on("senderDisconnect", (ev: {cid: string, universe: number, lastPacket: Packet}) => {
  ...
});

additionally I've added default values to comply with ts-strict and converted SendersData to interface SendersData

- converted from string to [cid, universe]
- renamed from pid to sid (sender-id)
@hansSchall
Copy link
Contributor Author

hansSchall commented May 16, 2022

There are two known bugs in the current version:

The first one affects the sender-id storage (This is already 90% fixed; has something to do with the key equality in a JS Map)

The other one appears if multiple universes are merged. In some circumstances the second universe is not merged.

I am working on a project, where up to 4 sources send to different universes on multiple priorities, so I can test the merging functionality carefully.

EDIT: they are all fixed by 2343cc6

hansSchall and others added 9 commits May 16, 2022 19:13
- fix multiple universes bug (add universe equality constraint in merge core)
- fix sender-id bugs (identify senders by a string instead of a [string,number]
- add .on() typescript call signatures
- add .clearCache()
- add .on("changesDone")
- fix spelling 'senderDis*C*onnect
- improved multi-universe management
- improved timeout management
- improved sender/universe storage
@k-yle
Copy link
Owner

k-yle commented Mar 11, 2024

Thanks again for making this PR. My original concerns from #43 (comment) still apply, but firstly: the performance of nodejs v21's EventEmitter is much better than node v13, and secondly: I'd rather merge this PR than have it sit around for any longer.

@k-yle k-yle merged commit b494a9b into k-yle:main Mar 11, 2024
8 of 12 checks passed
k-yle added a commit that referenced this pull request Jul 21, 2024
k-yle added a commit that referenced this pull request Jul 21, 2024
cherypick changes from #43 into this branch
k-yle added a commit to mutec/sACN that referenced this pull request Jul 22, 2024
k-yle added a commit to mutec/sACN that referenced this pull request Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support merging from multiple controllers
2 participants