KeptPace from settings: a module's declared pace paces its kept calls
busretry.ReadPace sets the kept-call pace from kept-call-pace-first and kept-call-pace-max through the one settings reader; process.Connect and a bundle's Serve read it at their start and refuse a value that is no duration. Builds: design 47 H2 §775, §781; H-A-370
This commit is contained in:
@@ -14,6 +14,9 @@ import (
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
"github.com/nats-io/nats.go/jetstream"
|
||||
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/busretry"
|
||||
)
|
||||
|
||||
// 1171/AC2: given an account file broker-<process id> in the controller's form {url, fingerprint, node,
|
||||
@@ -342,6 +345,12 @@ func subTheOwnBuildIsTheFingerprintTheProcessWasStartedWith(t *testing.T) {
|
||||
t.Errorf("%s: the process's own build is not said at its start: %+v", name, said)
|
||||
}
|
||||
}
|
||||
// Design 47 H2 §775, §781: Connect reads the module's kept-call pace from its settings, and refuses one that is no
|
||||
// duration, naming it.
|
||||
t.Setenv(stdio.SettingWord(busretry.PaceFirstSetting), "soon")
|
||||
if _, err := Connect(Account{URL: "nats://127.0.0.1:1", User: "n1.m"}); err == nil || !strings.Contains(err.Error(), "kept-call-pace-first") {
|
||||
t.Errorf("a pace that is no duration connected: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestReadAccountYieldsEveryFieldAndToleratesClaims runs the tests of this package that were merged to keep the module within its test budget (design 47 G §419), each as a subtest.
|
||||
|
||||
@@ -12,6 +12,9 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/nats-io/nats.go"
|
||||
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/busretry"
|
||||
)
|
||||
|
||||
// Conn is one process's own connection to the bus (novox/hq ADR 0436 clause 4): dialled with the account
|
||||
@@ -54,6 +57,9 @@ var refusedPublish = regexp.MustCompile(`(?i)Publish to "(\S+)"`)
|
||||
// at once.
|
||||
func Connect(account Account, opts ...nats.Option) (*Conn, error) {
|
||||
OwnBuild()
|
||||
if err := busretry.ReadPace(stdio.SettingDuration); err != nil {
|
||||
return nil, fmt.Errorf("the kept-call pace of the process account %s: %w", account.User, err)
|
||||
}
|
||||
c := &Conn{account: account, pending: map[string]map[uint64]context.CancelCauseFunc{}}
|
||||
nc, err := nats.Connect(account.URL, c.options(opts)...)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user