A module's new state reached the bus only when the controller started (issue 1790, met three times: puts, queues, mesh-vault's bus-accounts). The operator allowed one more grant in the controller's composer on 2026-10-26 08:54, creation only: the part's process now creates each bucket, log or stream a placed module's manifest declares and the bus lacks, with the same configuration the controller asserts (mesh-sdk BucketStreamConfig, Log.Config, ModuleStreamConfig), on the event that brought the manifest, never on a timer. It says asserted and logs one line per module; a stream the bus holds is never updated or deleted, its difference only said; a create refused is said and tried at the next event; one created at this manifest and gone since is made again only by hand. grants_assert asks the process to do the same for one module now. The user list, the grants and any change to a held stream stay in shadow. mesh-sdk moves to fix/1790-grants-create-buckets, whose composer grants this, so the shadow list is composed as the controller's. Issue: 1790
35 lines
941 B
Go
35 lines
941 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/nats-io/nats.go/jetstream"
|
|
|
|
"mesh-grants/internal/grants"
|
|
)
|
|
|
|
// creating creates a stream a manifest declares that the bus lacks (issue 1790; the operator, 2026-10-26 08:54): the
|
|
// create alone, which the account is granted by the stream's name, never an update or a delete. The one place the part
|
|
// creates on the bus.
|
|
type creating struct {
|
|
ctx context.Context
|
|
js jetstream.JetStream
|
|
}
|
|
|
|
func (c creating) CreateDeclared(cfg jetstream.StreamConfig) error {
|
|
ctx, cancel := context.WithTimeout(c.ctx, requestWithin)
|
|
defer cancel()
|
|
_, err := c.js.CreateStream(ctx, cfg)
|
|
switch {
|
|
case err == nil:
|
|
return nil
|
|
case errors.Is(err, jetstream.ErrStreamNameAlreadyInUse):
|
|
return grants.ErrHeld
|
|
case errors.Is(err, context.DeadlineExceeded):
|
|
return fmt.Errorf("no answer in %s: a create the bus refuses is answered by none (%w)", requestWithin, err)
|
|
}
|
|
return err
|
|
}
|