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

DPLT-1076 create node worker to process real time streams #159

Merged

Conversation

morgsmccauley
Copy link
Collaborator

@morgsmccauley morgsmccauley commented Aug 1, 2023

This PR creates a Node app for processing the real-time Redis streams.

I've created a new top-level directory called runner/ to house this code. It borrows most of the code from indexer-js-queue-handler, but I have:

  • Removed all unused code - functional context etc.
  • Converted to TypeScript
  • Added Eslint and formatted
  • Restructured file/directory structure

I've added separate commits for copying the file over, and adding the above modifications if you are interested/concerned about the changes. The core logic is in runner/src/index.ts, most other code has remained the same aside from the above.

To process each stream, runner will continuously poll the indexers set to get the list of current indexers, and spin out a promise which polls its respective stream. As Node is single-threaded, this code isn't truely concurrent, and all JS execution will be executed sequentially. However, I/O will be offloaded to the system allowing for some concurrency, and hopefully a system which is still somewhat performant. I'll address concurrency in future PRs.

@morgsmccauley morgsmccauley force-pushed the DPLT-1076-create-node-worker-to-process-real-time-streams branch 3 times, most recently from 1e4313d to fcb0bcd Compare August 1, 2023 20:44
@morgsmccauley morgsmccauley force-pushed the DPLT-1076-create-node-worker-to-process-real-time-streams branch from 79cfae0 to aeaeaef Compare August 2, 2023 02:49
@morgsmccauley morgsmccauley marked this pull request as ready for review August 2, 2023 03:26
@morgsmccauley morgsmccauley requested a review from a team as a code owner August 2, 2023 03:26
storage::sadd(
context.redis_connection_manager,
storage::INDEXER_SET_KEY,
indexer_function.get_full_name(),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Storing the indexer name alone to make it easier to build the many other keys related to this indexer, i.e. :storage and :stream


const results = await client.xRead(
{ key: generateStreamKey(indexerName), id },
// can't use blocking calls as running single threaded
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This might not be true, I'll investigate more later

@morgsmccauley
Copy link
Collaborator Author

Merging as I'd like to test the related infra. Feel free to comment retrospectively.

@morgsmccauley morgsmccauley merged commit c64e862 into main Aug 4, 2023
3 checks passed
@morgsmccauley morgsmccauley deleted the DPLT-1076-create-node-worker-to-process-real-time-streams branch August 4, 2023 04:43
@gabehamilton
Copy link
Collaborator

Looks good!

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.

2 participants