()
| 53 | } |
| 54 | |
| 55 | func ExampleRoundRobin() { |
| 56 | r, _ := New() |
| 57 | for _, server := range servers { |
| 58 | _ = r.AddServer(server.url, server.weight) |
| 59 | } |
| 60 | |
| 61 | fmt.Println(r.NextServer().Host) |
| 62 | fmt.Println(r.NextServer().Host) |
| 63 | fmt.Println(r.NextServer().Host) |
| 64 | fmt.Println(r.NextServer().Host) |
| 65 | fmt.Println(r.NextServer().Host) |
| 66 | fmt.Println(r.NextServer().Host) |
| 67 | fmt.Println(r.NextServer().Host) |
| 68 | fmt.Println(r.NextServer().Host) |
| 69 | fmt.Println(r.NextServer().Host) |
| 70 | |
| 71 | // Output: |
| 72 | // 192.168.1.10 |
| 73 | // 192.168.1.10 |
| 74 | // 192.168.1.11 |
| 75 | // 192.168.1.10 |
| 76 | // 192.168.1.11 |
| 77 | // 192.168.1.12 |
| 78 | // 192.168.1.10 |
| 79 | // 192.168.1.11 |
| 80 | // 192.168.1.12 |
| 81 | } |
| 82 | |
| 83 | func BenchmarkNext(b *testing.B) { |
| 84 | r, _ := New() |
nothing calls this directly
no test coverage detected