Read a per-node state through mesh-sdk's pernode package, so the runtime and a process share one copy of its rules
Replaces the runtime's own bucket listing, advisory hearing and per-bucket bookkeeping; the bound on progress and the runtime's shapes stay here. ADR 0593 §6. Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
This commit is contained in:
@@ -85,9 +85,6 @@ func (c *Conn) issuedState(module, name string) (StateIssued, error) {
|
||||
module, name, issued)
|
||||
}
|
||||
|
||||
// errNoBucket marks a bucket the bus does not hold yet.
|
||||
var errNoBucket = errors.New("no such bucket")
|
||||
|
||||
func (c *Conn) bucket(ctx context.Context, s StateIssued) (jetstream.KeyValue, error) {
|
||||
js, err := jetstream.New(c.nc)
|
||||
if err != nil {
|
||||
@@ -97,7 +94,7 @@ func (c *Conn) bucket(ctx context.Context, s StateIssued) (jetstream.KeyValue, e
|
||||
if err != nil {
|
||||
if errors.Is(err, jetstream.ErrBucketNotFound) {
|
||||
return nil, fmt.Errorf("the state %q is issued and its bucket is not on the bus yet: the mesh "+
|
||||
"creates it from the catalogue on its next raise: %w", s.Name, errNoBucket)
|
||||
"creates it from the catalogue on its next raise", s.Name)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
@@ -122,17 +119,12 @@ func (c *Conn) StateGet(module, name, key string) (*StateEntry, error) {
|
||||
return nil, err
|
||||
}
|
||||
if s.PerNode {
|
||||
if s, err = nodeBucketOf(s, key); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c.perNodeGet(s, key)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), StateTimeout)
|
||||
defer cancel()
|
||||
kv, err := c.bucket(ctx, s)
|
||||
if err != nil {
|
||||
if s.PerNode && errors.Is(err, errNoBucket) {
|
||||
return nil, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
e, err := kv.Get(ctx, key)
|
||||
@@ -422,7 +414,7 @@ func (c *Conn) StateWatch(module, name, pattern string, deliver func(StateChange
|
||||
filter = strings.Join(parts, ".")
|
||||
}
|
||||
if s.PerNode {
|
||||
return c.perNodeWatch(module, s, filter, deliver)
|
||||
return c.perNodeWatch(module, s, pattern, deliver)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), StateTimeout)
|
||||
kv, err := c.bucket(ctx, s)
|
||||
|
||||
Reference in New Issue
Block a user