本文整理匯總了Golang中github.com/cloudfoundry-incubator/routing-api/db.DB.SaveRouterGroup方法的典型用法代碼示例。如果您正苦於以下問題:Golang DB.SaveRouterGroup方法的具體用法?Golang DB.SaveRouterGroup怎麽用?Golang DB.SaveRouterGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry-incubator/routing-api/db.DB
的用法示例。
在下文中一共展示了DB.SaveRouterGroup方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: seedRouterGroups
func seedRouterGroups(cfg config.Config, logger lager.Logger, database db.DB) {
// seed router groups from config
if len(cfg.RouterGroups) > 0 {
routerGroups, _ := database.ReadRouterGroups()
// if config not empty and db is empty, seed
if len(routerGroups) == 0 {
for _, rg := range cfg.RouterGroups {
guid, err := uuid.NewV4()
if err != nil {
logger.Error("failed to generate a guid for router group", err)
os.Exit(1)
}
rg.Guid = guid.String()
logger.Info("seeding", lager.Data{"router-group": rg})
err = database.SaveRouterGroup(rg)
if err != nil {
logger.Error("failed to save router group from config", err)
os.Exit(1)
}
}
}
}
}
示例2:
Expect(fakeKeysAPI.DeleteCallCount()).To(Equal(1))
})
})
})
})
Context("RouterGroup", func() {
Context("Save", func() {
Context("when router group is missing a guid", func() {
It("does not save the router group", func() {
routerGroup := models.RouterGroup{
Name: "router-group-1",
Type: "tcp",
ReservablePorts: "10-20,25",
}
err = etcd.SaveRouterGroup(routerGroup)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("missing guid"))
})
})
Context("when router group does not exist", func() {
It("saves the router group", func() {
g, err := uuid.NewV4()
Expect(err).NotTo(HaveOccurred())
guid := g.String()
routerGroup := models.RouterGroup{
Name: "router-group-1",
Type: "tcp",
Guid: guid,