Register a new module from the builder's first done key and ask no first build; its condition reads the key and names a manifest word this controller does not read (issue 1851, A5a, A5b)
This commit is contained in:
@@ -158,6 +158,39 @@ func (r Reader) ModuleAt(ctx context.Context, module, commit string) (delivery.M
|
||||
return pickAt(module, commit, values)
|
||||
}
|
||||
|
||||
// Modules is every module the indexer holds a trunk value of, by module: the value it holds now. A value that does not
|
||||
// decode is left out and said in unread.
|
||||
func (r Reader) Modules(ctx context.Context) (values map[string]delivery.Module, unread map[string]error, err error) {
|
||||
kv, err := r.bucket(ctx, delivery.ModulesBucket)
|
||||
if err != nil || kv == nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
keys, err := kv.Keys(ctx)
|
||||
if errors.Is(err, jetstream.ErrNoKeysFound) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("listing the indexer's modules: %w", err)
|
||||
}
|
||||
values, unread = map[string]delivery.Module{}, map[string]error{}
|
||||
for _, key := range keys {
|
||||
e, err := kv.Get(ctx, key)
|
||||
if errors.Is(err, jetstream.ErrKeyNotFound) {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("the indexer's value of %s: %w", key, err)
|
||||
}
|
||||
m, err := delivery.DecodeModule(e.Value())
|
||||
if err != nil {
|
||||
unread[key] = err
|
||||
continue
|
||||
}
|
||||
values[key] = m
|
||||
}
|
||||
return values, unread, nil
|
||||
}
|
||||
|
||||
// pickAt is, of a key's values oldest first, the newest whose commit is commit (any, with commit empty); values that
|
||||
// do not decode are passed over, and one of them is said when nothing else is found.
|
||||
func pickAt(module, commit string, values [][]byte) (delivery.Module, error) {
|
||||
|
||||
@@ -124,6 +124,11 @@ func TestTheControllerReadsTheBuildersKeysAndTheIndexersValues(t *testing.T) {
|
||||
if _, err := r.ModuleAt(ctx, "x", "9999999999"); !errors.Is(err, ErrNoValue) {
|
||||
t.Fatalf("a commit the indexer never wrote: %v", err)
|
||||
}
|
||||
put(t, modules, "broken", []byte("{not json"))
|
||||
all, unread, err := r.Modules(ctx)
|
||||
if err != nil || len(all) != 1 || all["x"].Commit != "3333333333" || unread["broken"] == nil {
|
||||
t.Fatalf("every module's value now: %+v %v %v", all, unread, err)
|
||||
}
|
||||
}
|
||||
|
||||
// The controller's account reaches the builder's and the indexer's buckets: it is granted the JetStream API whole.
|
||||
|
||||
Reference in New Issue
Block a user