當前位置: 首頁>>代碼示例>>Golang>>正文


Golang shadow.Application類代碼示例

本文整理匯總了Golang中github.com/kihamo/shadow.Application的典型用法代碼示例。如果您正苦於以下問題:Golang Application類的具體用法?Golang Application怎麽用?Golang Application使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Application類的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Init

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
}
開發者ID:kihamo,項目名稱:shadow-sender,代碼行數:9,代碼來源:sender.go

示例2: Init

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
}
開發者ID:kihamo,項目名稱:shadow-sender,代碼行數:9,代碼來源:resource.go

示例3: Init

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
}
開發者ID:kihamo,項目名稱:shadow-sms,代碼行數:11,代碼來源:resource.go

示例4: Init

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
}
開發者ID:kihamo,項目名稱:shadow-api,代碼行數:11,代碼來源:service.go

示例5: Init

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
}
開發者ID:kihamo,項目名稱:shadow-sms,代碼行數:11,代碼來源:service.go

示例6: 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")
}
開發者ID:kihamo,項目名稱:shadow-api,代碼行數:13,代碼來源:procedure.go

示例7: Init

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
}
開發者ID:kihamo,項目名稱:shadow-aws,代碼行數:13,代碼來源:resource.go

示例8: 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
}
開發者ID:kihamo,項目名稱:shadow-sender,代碼行數:51,代碼來源:service.go

示例9: 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")
}
開發者ID:kihamo,項目名稱:shadow-slack,代碼行數:14,代碼來源:command.go

示例10: Init

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)
}
開發者ID:kihamo,項目名稱:shadow-sender,代碼行數:18,代碼來源:api.go

示例11: Init

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
}
開發者ID:kihamo,項目名稱:shadow-slack,代碼行數:19,代碼來源:service.go


注:本文中的github.com/kihamo/shadow.Application類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。