You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I've worked on the plugin-server codebase the hardest thing for me has been keeping a clear view of how the program functions for two reasons:
It's hard to tell if a piece of code is called within the main thread, workers or both
It's hard to map out the message flow due to same or similar-meaning verbs being used all over the place: For example, what's the difference between ingesting and processing events, saveEvent/ingestEvent naming getting changed, processEventBatch being both a worker task name as well as a plugin method name etc.
Our codebase is currently split up up by functionality - e.g. one folder for ingestion-related logic, another for worker setup, another for plugin setup and so on. This makes sense but makes it hard to follow what code is worker-related, what is not.
Proposal for improving (1):
Let's create two subdirectories under src/ - src/main and src/workers and src/shared - along the internal service boundary lines. So code in src/workers contains everything needed to run the worker threads, src/main for the main thread and src/shared for any code shared between the two (e.g. implementation of createServer, DB etc).
Both src/worker and src/main import from src/shared but from no other directory.
Within each subdir, we can further divide the code up as we already do - e.g. plugins, ingestion, etc.
Figure out a way to use composition rather than putting most not all queries into one db.ts file.
As I've worked on the plugin-server codebase the hardest thing for me has been keeping a clear view of how the program functions for two reasons:
Our codebase is currently split up up by functionality - e.g. one folder for
ingestion-related logic, another forworkersetup, another forpluginsetup and so on. This makes sense but makes it hard to follow what code is worker-related, what is not.Proposal for improving (1):
src/-src/mainandsrc/workersandsrc/shared- along the internal service boundary lines. So code insrc/workerscontains everything needed to run the worker threads,src/mainfor the main thread andsrc/sharedfor any code shared between the two (e.g. implementation of createServer, DB etc).src/workerandsrc/mainimport fromsrc/sharedbut from no other directory.db.tsfile.