// Does a checkin with the requested client. returns the // router table revision of the connection. func (this *Manager) Checkin(client client.Client) (int64, error) { response, err := client.ApiCallSync(cheshire.NewRequest("/chs/checkin", "GET"), 10*time.Second) if err != nil { return int64(0), err } revision := response.MustInt64("router_table_revision", int64(0)) return revision, nil }
func syncTest(client c.Client, total int) { start := time.Now().Unix() for i := 0; i < total; i++ { if i%1000 == 0 { log.Printf("Sending %d", i) } _, err := client.ApiCallSync(cheshire.NewRequest("/ping", "GET"), 2*time.Second) if err != nil { log.Printf("apicall error %s", err) } } log.Printf("Pinged %d in %d", total, (time.Now().Unix() - start)) }
// Finds the RouterTable from the given client // func RequestRouterTable(c client.Client) (*RouterTable, error) { response, err := c.ApiCallSync(cheshire.NewRequest(ROUTERTABLE_GET, "GET"), 10*time.Second) if err != nil { return nil, err } if response.StatusCode() != 200 { return nil, fmt.Errorf("Error from server %d %s", response.StatusCode(), response.StatusMessage()) } mp, ok := response.GetDynMap("router_table") if !ok { return nil, fmt.Errorf("No router_table in response : %s", response) } table, err := ToRouterTable(mp) if err != nil { return nil, err } return table, nil }