Exemple #1
0
func (s *Server) instantiate(m *services.Module) (interface{}, error) {
	inj := inject.NewInjector()
	inj.Instance(s.Broker)
	inj.Factory(func() services.Config {
		return nullConfig{}
	})
	inj.Factory(func() sarif.Conn {
		return s.Broker.NewLocalConn()
	})
	inj.Factory(func() *sarif.Client {
		c := sarif.NewClient("js/" + m.Name)
		c.Connect(s.Broker.NewLocalConn())
		return c
	})
	return inj.Create(m.NewInstance)
}
Exemple #2
0
func (app *App) Inject(name string, container interface{}) error {
	inj := inject.NewInjector()
	app.SetupInjector(inj, name)
	return inj.Inject(container)
}
Exemple #3
0
func (s *Server) instantiate(m *services.Module) (interface{}, error) {
	inj := inject.NewInjector()
	s.SetupInjector(inj, m.Name)
	return inj.Create(m.NewInstance)
}
Exemple #4
0
func (s *Server) Inject(name string, container interface{}) error {
	inj := inject.NewInjector()
	s.SetupInjector(inj, name)
	return inj.Inject(container)
}