func lookupPagedEdgeSets(ctx context.Context, tbl table.ProtoBatch, keys [][]byte) (<-chan edgeSetResult, error) { rs, err := tbl.LookupBatch(ctx, keys, (*srvpb.PagedEdgeSet)(nil)) if err != nil { return nil, err } ch := make(chan edgeSetResult) go func() { defer close(ch) for r := range rs { if r.Err == table.ErrNoSuchKey { log.Printf("Could not locate edges with key %q", r.Key) ch <- edgeSetResult{Err: r.Err} continue } else if r.Err != nil { ticket := strings.TrimPrefix(string(r.Key), edgeSetsTablePrefix) ch <- edgeSetResult{ Err: fmt.Errorf("edges lookup error (ticket %q): %v", ticket, r.Err), } continue } ch <- edgeSetResult{PagedEdgeSet: r.Value.(*srvpb.PagedEdgeSet)} } }() return ch, nil }
func lookupNodes(ctx context.Context, tbl table.ProtoBatch, keys [][]byte) (<-chan nodeResult, error) { rs, err := tbl.LookupBatch(ctx, keys, (*srvpb.Node)(nil)) if err != nil { return nil, err } ch := make(chan nodeResult) go func() { defer close(ch) for r := range rs { if r.Err == table.ErrNoSuchKey { log.Printf("Could not locate node with key %q", r.Key) ch <- nodeResult{Err: r.Err} continue } else if r.Err != nil { ticket := strings.TrimPrefix(string(r.Key), nodesTablePrefix) ch <- nodeResult{ Err: fmt.Errorf("lookup error for node %q: %v", ticket, r.Err), } continue } ch <- nodeResult{Node: r.Value.(*srvpb.Node)} } }() return ch, nil }