本文整理匯總了Golang中github.com/kihamo/shadow.Application.GetService方法的典型用法代碼示例。如果您正苦於以下問題:Golang Application.GetService方法的具體用法?Golang Application.GetService怎麽用?Golang Application.GetService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/kihamo/shadow.Application
的用法示例。
在下文中一共展示了Application.GetService方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Init
func (p *AbstractApiProcedure) Init(s shadow.Service, a *shadow.Application) error {
p.Application = a
p.Service = s
if apiService, err := a.GetService("api"); err == nil {
if castService, ok := apiService.(*ApiService); ok {
p.ApiService = castService
return nil
}
}
return errors.New("Api service not found")
}
示例2: Init
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
}
示例3: Init
func (c *AbstractSlackCommand) Init(s shadow.Service, a *shadow.Application) {
c.Application = a
c.Service = s
slackService, err := a.GetService("slack")
if err == nil {
if castService, ok := slackService.(*SlackService); ok {
c.SlackService = castService
return
}
}
panic("Slack service not found")
}