Skip to content

About

A lightweight helper library for composing modular services in Go applications using dependency injection.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

service-composer

test Go Reference

A lightweight helper library for composing modular services in Go applications using dependency injection.

Overview

service-composer provides a simple way to structure and compose services in Go applications by leveraging the do dependency injection container. It helps you organize your application into manageable modules with clear lifecycle management.

Installation

go get github.com/aklinkert/service-composer

Requires Go 1.25 or newer.

Features

  • Modular Architecture: Organize your application into self-contained modules
  • Dependency Injection: Built on top of the do DI container
  • Dependency Ordering: Modules declare DependsOn(); initialization runs in a stable topological order and fails on dependency cycles
  • Lifecycle Management: Clean startup and shutdown of services
  • Minimal Boilerplate: Focus on business logic, not wiring

Usage

Documentation and examples can be found in the GoDoc.

Modules may be registered concurrently, but the lifecycle methods (Initialize and Start) are not synchronized and must be called from a single goroutine once all modules are registered.

For a complete usage example, see example_test.go.

License

MIT License

Copyright (c) 2025 - present Alex Klinkert

About

A lightweight helper library for composing modular services in Go applications using dependency injection.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages