A command opens each store once, not once per machine
Working out what a machine should be reaches the identity context for its certificate and the licence context for its model access. Both were opened — and waited on — inside functions called for every node in a push. Two machines hid it. Fifty would be fifty connect-and-wait cycles for data that does not change while the push runs. So a command holds what it has open, and passes it. Each context is opened on first use rather than up front, because most commands need one and paying to reach three would be the same waste from the other side. The contexts stay separate, which is the point: this is one struct holding three connections to three databases, not one connection to a shared one. No context reaches another's store, and each still holds only its own credential (novox/hq ADR 0008). A pure move again — the gate is green before and after, and no test changed.
This commit is contained in:
@@ -83,13 +83,13 @@ func board() http.Handler {
|
||||
// The same answers for something that is not a person, from the same read. A board and a
|
||||
// script disagreeing about which machine is broken would be worse than either alone.
|
||||
mux.HandleFunc("/mesh.json", func(w http.ResponseWriter, r *http.Request) {
|
||||
inv, err := openInventory(r.Context())
|
||||
open, err := openStores(r.Context())
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusServiceUnavailable)
|
||||
return
|
||||
}
|
||||
defer inv.Close()
|
||||
asked, err := theThreeQuestions(r.Context(), inv)
|
||||
defer open.Close()
|
||||
asked, err := theThreeQuestions(r.Context(), open)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusServiceUnavailable)
|
||||
return
|
||||
@@ -108,13 +108,13 @@ func board() http.Handler {
|
||||
|
||||
// ask reads the mesh for one request.
|
||||
func ask(ctx context.Context) (view, error) {
|
||||
inv, err := openInventory(ctx)
|
||||
open, err := openStores(ctx)
|
||||
if err != nil {
|
||||
return view{}, err
|
||||
}
|
||||
defer inv.Close()
|
||||
defer open.Close()
|
||||
|
||||
asked, err := theThreeQuestions(ctx, inv)
|
||||
asked, err := theThreeQuestions(ctx, open)
|
||||
if err != nil {
|
||||
return view{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user