Skip to content

Composition Root in main() and wiring. #7

@JoTurk

Description

@JoTurk

Create a single composition root that constructs and wires all components with constructor injection.

I think we have some options.

  1. Manual DI
  • Pros: Explicit; No magic
  • Cons: Verbose, harder to test
  1. Google Wire
  • Pros: Compile-time checks
  • Cons: Codegen step, we'll have to add a build setup and script, using justfile or something, Wire is no longer maintained so we'll have to fork it.
  1. Uber Fx
  • Pros: Lifecycle hooks
  • Cons: Reflection/magic, slower
    (we're open to any other option)

tasks

  • Return cleanup functions from constructors. aggregate and defer
  • App starts with explicit wiring. no hidden globals
  • Global context manager and graceful startup and shutdown with timeouts for modules.
  • go test can construct core with fakes

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