Skip to content

Instantly share code, notes, and snippets.

@liampulles
Created April 18, 2022 09:42
Show Gist options
  • Save liampulles/f62dbe42763a686df8fe1935fad4f059 to your computer and use it in GitHub Desktop.
Save liampulles/f62dbe42763a686df8fe1935fad4f059 to your computer and use it in GitHub Desktop.
Example of wiring from Matchstick Video
// CreateServerFactory injects all the dependencies needed to create
// http.ServerFactory
func CreateServerFactory(source goConfig.Source) (http.ServerFactory, error) {
// Each "tap" below indicates a level of dependency
configStore, err := config.NewStoreImpl(
source,
)
if err != nil {
return nil, err
}
errorParser := adapterDb.NewErrorParserImpl()
// --- NEXT TAP ---
helperService := sql.NewHelperServiceImpl(errorParser)
databaseService, err := db.NewDatabaseServiceImpl(
configStore,
)
if err != nil {
return nil, err
}
inventoryItemConstructor := entity.NewInventoryItemConstructorImpl()
muxWrapper := mux.NewWrapperImpl()
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment