Пример #1
0
func (s *Server) SetupInjector(inj *inject.Injector, name string) {
	cname := name
	if s.ServerConfig.Name != "" {
		cname = s.ServerConfig.Name + "/" + name
	}
	c := sarif.NewClient(cname)
	c.Connect(s.Broker.NewLocalConn())
	c.SetLogger(s.Log)

	inj.Instance(s.Broker)
	inj.Factory(func() sarif.Conn {
		return s.Broker.NewLocalConn()
	})
	inj.Factory(func() *sarif.Client {
		return c
	})
	inj.Factory(func() services.Config {
		if !s.configStoreInitialized {
			return s.Config.Section(name)
		}
		cfg := config.NewConfigStore(c)
		cfg.Store.StoreName = s.ServerConfig.ConfigStore
		cfg.ConfigDir = s.Config.Dir()
		return cfg
	})
}
Пример #2
0
func (app *App) SetupInjector(inj *inject.Injector, name string) {
	inj.Instance(app.Log)
	inj.Factory(func() services.Config {
		return app.Config.Section(name)
	})
	inj.Factory(func() sarif.Logger {
		return app.Log
	})
}