Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Proposal: Refactor the codebase to reflect internal service boundaries #261

Description

@macobo

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:

  1. It's hard to tell if a piece of code is called within the main thread, workers or both
  2. 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):

  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).
  2. Both src/worker and src/main import from src/shared but from no other directory.
  3. Within each subdir, we can further divide the code up as we already do - e.g. plugins, ingestion, etc.
  4. Figure out a way to use composition rather than putting most not all queries into one db.ts file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions