本文整理匯總了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)
}
}