Exemplo n.º 1
0
func (r *SenderResource) Init(a *shadow.Application) error {
	resourceConfig, err := a.GetResource("config")
	if err != nil {
		return err
	}
	r.config = resourceConfig.(*resource.Config)

	return nil
}
Exemplo n.º 2
0
func (r *DaoResource) Init(a *shadow.Application) error {
	resourceDatabase, err := a.GetResource("database")
	if err != nil {
		return err
	}

	r.database = resourceDatabase.(*database.Database)
	return nil
}
Exemplo n.º 3
0
func (r *Resource) Init(a *shadow.Application) error {
	resourceConfig, err := a.GetResource("config")
	if err != nil {
		return err
	}
	r.config = resourceConfig.(*config.Resource)

	r.application = a

	return nil
}
Exemplo n.º 4
0
func (s *ApiService) Init(a *shadow.Application) error {
	s.application = a

	resourceConfig, err := a.GetResource("config")
	if err != nil {
		return err
	}
	s.config = resourceConfig.(*config.Resource)

	return nil
}
Exemplo n.º 5
0
func (s *SmsService) Init(a *shadow.Application) error {
	s.application = a

	resourceSmsIntel, err := a.GetResource("smsintel")
	if err != nil {
		return err
	}
	s.sms = resourceSmsIntel.(*smsintel.Resource)

	return nil
}
Exemplo n.º 6
0
func (r *Resource) Init(a *shadow.Application) error {
	r.application = a
	r.services = map[string]interface{}{}

	resourceConfig, err := a.GetResource("config")
	if err != nil {
		return err
	}

	r.config = resourceConfig.(*config.Resource)

	return nil
}
Exemplo n.º 7
0
func (p *AbstractSenderApiProcedure) Init(s shadow.Service, a *shadow.Application) {
	p.AbstractApiProcedure.Init(s, a)

	resourceConfig, _ := a.GetResource("config")
	p.Config = resourceConfig.(*r.Config)

	resourceLogger, _ := a.GetResource("logger")
	p.Logger = resourceLogger.(*r.Logger).Get("sender")

	resourceTasks, _ := a.GetResource("tasks")
	p.Tasks = resourceTasks.(*r.Dispatcher)

	resourceDao, _ := a.GetResource("sender.dao")
	p.Dao = resourceDao.(*dao.DaoResource)

	resourceSender, _ := a.GetResource("sender")
	p.Sender = resourceSender.(*resource.SenderResource)
}
Exemplo n.º 8
0
func (s *SlackService) Init(a *shadow.Application) error {
	s.application = a

	resourceConfig, err := a.GetResource("config")
	if err != nil {
		return err
	}
	s.config = resourceConfig.(*resource.Config)

	resourceLogger, err := a.GetResource("logger")
	if err != nil {
		return err
	}
	s.logger = resourceLogger.(*resource.Logger).Get(s.GetName())

	s.Commands = map[string]SlackCommand{}

	return nil
}
Exemplo n.º 9
0
func (s *SenderService) Init(a *shadow.Application) error {
	s.application = a

	resourceSender, err := a.GetResource("sender")
	if err != nil {
		return err
	}
	s.Sender = resourceSender.(*resource.SenderResource)

	resourceConfig, err := a.GetResource("config")
	if err != nil {
		return err
	}
	s.config = resourceConfig.(*r.Config)

	serviceFrontend, err := a.GetService("frontend")
	if err != nil {
		return err
	}
	s.FrontendService = serviceFrontend.(*frontend.FrontendService)

	resourceLogger, err := a.GetResource("logger")
	if err != nil {
		return err
	}
	s.Logger = resourceLogger.(*r.Logger).Get(s.GetName())

	resourceStorage, err := a.GetResource("database")
	if err != nil {
		return err
	}
	s.storage = resourceStorage.(*database.Database).GetStorage()

	s.storage.AddTableWithName(model.Application{}, model.TableApplications).ColMap("token").SetUnique(true)
	s.storage.AddTableWithName(model.Endpoint{}, model.TableEndpoints).ColMap("token").SetUnique(true)
	s.storage.AddTableWithName(model.Message{}, model.TableMessages)
	s.storage.AddTableWithName(model.Publish{}, model.TablePublishes)

	if err = s.storage.CreateTablesIfNotExists(); err != nil {
		return err
	}

	// provides
	s.Balances = map[string]float64{}

	if s.Sender.HasProvider("smsintel") {
		s.Balances["smsintel"] = float64(0)
	}

	return nil
}