Exemple #1
0
func writeNodes(t table.Proto, nodeEntries <-chan *spb.Entry, nodes chan<- *srvpb.Node) error {
	defer close(nodes)
	for node := range collectNodes(nodeEntries) {
		nodes <- node
		if err := t.Put(xsrv.NodeKey(node.Ticket), node); err != nil {
			return err
		}
	}
	return nil
}
Exemple #2
0
func writeNodes(ctx context.Context, t table.Proto, nodeEntries <-chan *spb.Entry, nodes chan<- *srvpb.Node) error {
	defer close(nodes)
	defer drainEntries(nodeEntries) // ensure channel is drained on errors
	for node := range collectNodes(nodeEntries) {
		nodes <- node
		if err := t.Put(ctx, xrefs.NodeKey(node.Ticket), node); err != nil {
			return err
		}
	}
	return nil
}