Refactor DI factory picker to use types instead of strings

Our DI system was patched to allow creation of singletons using a string as the map key instead of the interface type. Now that we have the factory picker code integrated allowing overriding of factories for singleton and non-singleton instances, the use of strings makes the system harder to use.

This issue is to refactor the DI system to use the interface type instead of a hard-coded string name for singleton types.

When calling asSingleton, the user must take care to use the interface type in the factory signature instead of the concreate type. This goes against the Wire packages manual, but is necessary for our usage.

func InitializeAuthServicer(cfg *config.Config, log browserk.Log) (browserk.AuthServicer, error) {
	return asSingleton(func() (browserk.AuthServicer, error) {
		return InitializeAuthService(cfg, log)
	})
}

This in turn will allow registering overrides using the interface type:

di.RegisterOverride(func() (browserk.AuthServicer, error) {
		return mock.NewAuthService(), nil
	})

Implementation

  • Issues:
    • Groups of values for a single type
    • Multiple interface types for a single concreate implementation that is a singleton
Edited by 🤖 GitLab Bot 🤖