本文整理汇总了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,