README: a Factories section - #49
Merged
Merged
Conversation
There is no transient lifetime, and the README never said what to do instead. The new section, in the Scopes part, says it: a value made fresh on every use is a function, registered like any service under a named function type; the container builds the factory once and never sees what it makes, so the products are the caller's to release or the factory's to pool; and a value that needs a lifecycle of its own is Scoped, resolved from a child scope per unit of work and stopped with it. One line each on samber/do's untracked ProvideTransient and on fx, which has no transient and uses the same function. examples/factory/main.go is the embedded program, run in CI beside the other short examples. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is no transient lifetime, and the README never said what to do instead. This adds
#### Factoriesto the Scopes part, between "Request scopes" and "Groups":ExplainandWirehave a name to show.*sql.Connis, or the factory's to pool.Scoped(), resolved from a child scope per unit of work and stopped with it.ProvideTransientinstances are not tracked either (checked in v2.1.0's source:shutdownandhealthcheckare no-ops), and on fx, which has no transient and uses the same function.examples/factory/main.gois the embedded program, 41 lines, shown open with its output. It is added to the CI list of short examples that are run as well as compiled.Docs only: no CHANGELOG entry. embedmd is in sync, the examples module vets and tests, gofmt is clean.
🤖 Generated with Claude Code