本文整理汇总了Golang中github.com/google/seesaw/ncc/client.NCC.IPVSAddService方法的典型用法代码示例。如果您正苦于以下问题:Golang NCC.IPVSAddService方法的具体用法?Golang NCC.IPVSAddService怎么用?Golang NCC.IPVSAddService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/google/seesaw/ncc/client.NCC
的用法示例。
在下文中一共展示了NCC.IPVSAddService方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ipvsTests
func ipvsTests(ncc client.NCC) {
// Manipulate the IPVS table.
if err := ncc.IPVSFlush(); err != nil {
log.Fatalf("Failed to flush the IPVS table: %v", err)
}
log.Printf("Adding IPVS service %v with %d destinations", testSvc, len(testSvc.Destinations))
if err := ncc.IPVSAddService(testSvc); err != nil {
log.Fatalf("Failed to add IPVS service: %v", err)
}
svcs, err := ncc.IPVSGetServices()
if err != nil {
log.Fatalf("Failed to get IPVS services: %v", err)
}
for _, svc := range svcs {
log.Printf("Got IPVS service %v with %d destinations",
svc, len(svc.Destinations))
}
if len(svcs) != 1 {
log.Fatalf("IPVSGetServices returned %d services, expected 1", len(svcs))
}
if len(svcs[0].Destinations) != len(testSvc.Destinations) {
log.Fatalf("IPVSGetServices returned %d destinations, expected %d",
len(svcs[0].Destinations), len(testSvc.Destinations))
}
dst := testSvc.Destinations[0]
if err := ncc.IPVSDeleteDestination(testSvc, dst); err != nil {
log.Fatalf("Failed to delete destination: %v", err)
}
svc, err := ncc.IPVSGetService(testSvc)
if err != nil {
log.Fatalf("Failed to get IPVS service: %v", err)
}
if len(svc.Destinations) != len(testSvc.Destinations)-1 {
log.Fatalf("IPVSGetService returned %d destinations, expected %d",
len(svc.Destinations), len(testSvc.Destinations)-1)
}
ipvsGetLoadTest(4, 10*time.Second)
if err := ncc.IPVSDeleteService(testSvc); err != nil {
log.Fatalf("Failed to delete IPVS service: %v", err)
}
ipvsAddLoadTest(ncc, 20, 50)
// Clean up after ourselves...
if err := ncc.IPVSFlush(); err != nil {
log.Fatalf("Failed to flush the IPVS table: %v", err)
}
}