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


Golang NCC.IPVSAddService方法代碼示例

本文整理匯總了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)
	}
}
開發者ID:Cepave,項目名稱:lvs-metrics,代碼行數:55,代碼來源:main.go


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