package inventory import "context" // RecordRefused keeps that the mesh refused to register a build's outcome, and why (novox/hq issue 1708): the build // record says the builder's words, which worked, and the look that settles a plan from the records reads this to fail // it instead. The first refusal of an id stands. func (i *Inventory) RecordRefused(ctx context.Context, id, module, why string) error { _, err := i.store.Pool().Exec(ctx, `insert into build_refused (id, module, why) values ($1, $2, $3) on conflict (id) do nothing`, id, module, why) return err } // RefusedOf is why each of these builds' registration was refused, by id; a build not refused is absent. func (i *Inventory) RefusedOf(ctx context.Context, ids []string) (map[string]string, error) { out := map[string]string{} if len(ids) == 0 { return out, nil } rows, err := i.store.Pool().Query(ctx, `select id, why from build_refused where id = any($1)`, ids) if err != nil { return nil, err } defer rows.Close() for rows.Next() { var id, why string if err := rows.Scan(&id, &why); err != nil { return nil, err } out[id] = why } return out, rows.Err() }