What I do
Create use case implementations with consistent structure.
When to use me
Adding new business operations.
Pattern
go
type (
XxxInput struct { ... }
XxxStore interface { ... }
Xxx interface { Handle(context.Context, XxxInput) (XxxOutput, error) }
xxx struct { store XxxStore; clock usecase.Clock }
)
func NewXxx(store XxxStore, clock usecase.Clock) *xxx { ... }
func (uc *xxx) Handle(ctx context.Context, input XxxInput) (XxxOutput, error) { ... }
Rules
- •Unexported implementation type, exported constructor
- •Accept interfaces for dependencies
- •Return usecase.Error for errors
- •Use todo.TodoOutput or create custom Output type