scaffoldedsample

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 5 Imported by: 0

README

ScaffoldedSample module (generated)

This directory was generated by tools/scaffold (see docs/planning/scaffolding-and-test-harness-guide.md) using the recommended domain/ports/service/adapters/module.go layout. Regeneration overwrites these files, so keep custom logic elsewhere if you plan to regenerate.

Regenerate with:

go run ./tools/scaffold/cmd/scaffold -name scaffolded-sample -out <parent-dir> -force

Layout

  • domain/ — the ScaffoldedSample value type.
  • ports/ — the Repository (outbound) and Service (inbound) interfaces.
  • service/ — the Service implementation, constructor-injected.
  • adapters/ — an in-memory Repository implementation.
  • module.go — the modulex.Module composition root.

Constructor injection vs. typed service location

service.New takes its ports.Repository dependency as a constructor parameter — this is the generated default and the recommended pattern. ports.ServiceKey additionally registers this module's ports.Service under a typed key so another module can resolve it via modulex.Resolve instead, if it cannot import this package directly. Prefer constructor injection; use the typed key only when you have a concrete reason to.

Tests

service/service_test.go covers the service's core behavior directly. module_test.go runs this module against Modulex's official test harness (modtest): lifecycle ordering, rollback on a sibling module's Init failure, resource ownership (the in-memory repository is released on Stop), and cancellation.

Documentation

Overview

Package scaffoldedsample was generated by tools/scaffold. See docs/planning/scaffolding-and-test-harness-guide.md and this feature's README.md for what was generated and how to regenerate it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	// contains filtered or unexported fields
}

Module acts as the composition root for the scaffolded-sample feature.

func NewModule

func NewModule() *Module

NewModule instantiates the module.

func (*Module) DependsOn

func (m *Module) DependsOn() []string

func (*Module) Init

func (m *Module) Init(ctx context.Context, reg modulex.Registry) error

Init wires the adapter and service using constructor injection (the generated default: service.New(m.repo)) and additionally registers ports.Service under its typed ServiceKey so other modules may resolve it via modulex.Resolve instead, if they prefer typed service location. See ports.ServiceKey's doc comment for when that's appropriate.

func (*Module) Name

func (m *Module) Name() string

func (*Module) Repository

func (m *Module) Repository() *adapters.InMemoryRepository

Repository exposes the module's underlying adapter for tests (see module_test.go), which use it with modtest.AssertResourceOwnership to verify Stop releases it. It is not a port, and other modules should not depend on it.

func (*Module) Stop

func (m *Module) Stop(ctx context.Context) error

Stop releases the resources Init acquired.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL