Builder: a version-released no reservation holds is acknowledged at once
Each version-released listed the module's reservations, one to three seconds on the serial events consumer, also for a version the builder no longer holds. Its series' one key now says whether a reservation holds it; one none holds is acknowledged with nothing listed. Builds: design 47 H2 H-A-514 addendum
This commit is contained in:
@@ -328,6 +328,10 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool {
|
||||
// release takes a released version in as the catalog's version-released says it (design 47 G §369): its reservation released,
|
||||
// its bound and publish item ended and its findings cleared. No git tag is written (design 47 H2 H-A-494).
|
||||
func (rv *reservations) release(ctx context.Context, ev meshcatalog.VersionReleasedEvent) error {
|
||||
// A version no reservation holds is acknowledged at once from its one key, never by listing (H-A-514 addendum).
|
||||
if held, err := rv.r.Holds(ctx, ev.Module, ev.Version); err == nil && !held {
|
||||
return nil
|
||||
}
|
||||
gone, err := rv.r.Released(ctx, ev.Module, ev.Version)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -24,8 +24,9 @@ import (
|
||||
|
||||
// memReserve is the state reserved in memory.
|
||||
type memReserve struct {
|
||||
vals map[string][]byte
|
||||
revs map[string]uint64
|
||||
vals map[string][]byte
|
||||
revs map[string]uint64
|
||||
lists int // how often its keys were listed
|
||||
}
|
||||
|
||||
func (m *memReserve) Get(_ context.Context, key string) ([]byte, uint64, bool, error) {
|
||||
@@ -47,6 +48,7 @@ func (m *memReserve) Update(_ context.Context, key string, v []byte, rev uint64)
|
||||
return rev + 1, nil
|
||||
}
|
||||
func (m *memReserve) KeysOf(_ context.Context, filter string) ([]string, error) {
|
||||
m.lists++
|
||||
var out []string
|
||||
for k := range m.vals {
|
||||
if versions.FilterMatches(filter, k) { // as the bus reads a filter
|
||||
@@ -213,6 +215,21 @@ func TestAReleasedVersionWritesNoTag(t *testing.T) {
|
||||
if all, _ := rv.r.All(ctx); len(all) != 0 {
|
||||
t.Fatalf("the released version still stands: %v", all)
|
||||
}
|
||||
// Design 47 H2 H-A-514 addendum: a version-released of a version no reservation holds is acknowledged at once from its
|
||||
// series' one key, the module's keys never listed.
|
||||
if _, err := rv.Reserve(ctx, "late", "0.2", []string{"late:bin"}, versions.Source{Repository: "o/l", Commit: "c1", Fingerprint: "fpL"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
store.lists = 0
|
||||
if m := release("late", "0.2.7"); !m.acked || m.naked || store.lists != 0 {
|
||||
t.Fatalf("a release no reservation holds: acked %v naked %v, the keys listed %d times; want it acknowledged with none", m.acked, m.naked, store.lists)
|
||||
}
|
||||
if _, standing, _ := rv.r.Of(ctx, "late", "0.2.0"); !standing {
|
||||
t.Fatal("a release of another version took the standing reservation late 0.2.0")
|
||||
}
|
||||
if _, err := rv.r.Drop(ctx, "late", "0.2"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The start check (H-A-484 c): a built reservation the catalog holds released is released at the start, no tag written; one
|
||||
// not built, or not released, stands.
|
||||
// Design 47 H2 H-A-492: at the start, a standing reservation with no digests recorded whose build key is done has them
|
||||
|
||||
@@ -534,6 +534,17 @@ func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version
|
||||
}
|
||||
}
|
||||
|
||||
// Holds answers whether a reservation holds module's version, from the one key of its series (design 47 H2 H-A-514
|
||||
// addendum): a version-released of a version none holds is acknowledged at once, never by listing the module's keys.
|
||||
func (r *Reserver) Holds(ctx context.Context, module, version string) (bool, error) {
|
||||
series, _, err := SplitVersion(version)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
cur, _, found, err := r.get(ctx, ReservedKey(module, series))
|
||||
return found && cur.Version == version, err
|
||||
}
|
||||
|
||||
// Released takes the catalog's version-released in: the key of that version is deleted, and every key of module's other
|
||||
// series (the manifest moved on). A key holding a newer reserved version of the same series stays. It answers the keys
|
||||
// deleted.
|
||||
|
||||
Reference in New Issue
Block a user