netube99 on X: one feature's settings are spread over pages that don't
say where the rest are. Plugins › Built-in had six rows (Key limits,
Groups, Rotation, Warm-ups, Middleware, Tools) with no page and no link,
so a user who turned one on was left to find where it shows. And the
Gateway page's one setting, Recent calls at a time, was a form under its
row in Plugins › Built-in, two pages from the calls it is about.
- pluginrt.Manifest gets Opens: the window page a built-in without a page
of its own is used on. budget → gateway (keys' limits), groups →
groups, rotation and warmups → providers (a provider's editor),
middleware and tools → plugins. builtinJSON sends it; featGo links to
that page by its sidebar name, as for a page plugin.
- A plugin with a page draws its settings there, not under its row
(renderBuiltins). The Gateway page draws its schema under Recent calls
(renderGatewayOwn), saves through /api/plugins/builtin as before, and
ends with a row "Port, allowed addresses and model ids" that opens
Settings › Network and sharing at the gateway's rows (4 languages).
Tests:
- TestBuiltinSaysWhereItsSettingsAre holds SetAt, Page and Opens per
built-in.
- builtins.test.cjs: no form in Built-in, and each Opens row's link says
its page's sidebar name. Its row reached by the wheel now counts the
window's bottom too, and frees a switch under the view's floating To
the bottom button by wheeling toward the window's middle: the rows grew
with their links, and WebKit de 420 left Usage's switch under it.
- gateway-own-settings.test.cjs (new): the setting under the calls,
translated, 20, picking 50 posts {id: gateway, config: {callsPage: 50}},
the row opens Settings › Network at #portList flashed; every language,
Chromium and WebKit, 1100 and 420, nothing past the window.
- builtin-places.test.cjs: Library's row now leads to Library.
Run at this tree (on origin/main e3f1efdaa), on mote:
- gofmt -l: nothing. go vet ./internal/gui ./internal/pluginrt
./plugins/..., GOOS=linux go vet -tags nogui, GOOS=windows go vet: ok.
- go test -run 'TestBuiltin|TestCoreScriptBudget|Translat' ./internal/gui
./internal/pluginrt ./plugins/...: ok.
- node --test builtins builtin-places websearch-places gateway-own-settings
gateway-keys-off i18n-en-no-cjk: 272 pass, 0 fail (both engines).
- i18n-keys: "a plugin's words are its own" red, the same on a clean
origin/main e3f1efdaa (#5332, #5327, #5482, #5426); fixed next.
Broken by hand: without budget's Opens, TestBuiltinSaysWhereItsSettingsAre
fails (want "gateway"); without the renderGatewayOwn call,
gateway-own-settings is 0 of 10 in Chromium.
Not tried: the real app; the whole GUI suite (next, behind suite.lock).
51 lines
1.7 KiB
Go
51 lines
1.7 KiB
Go
// Package rotation is the routings a provider or group can be set to
|
|
// besides Smart: In order, Until used up, In turn, Least used first,
|
|
// Use before expiry, By weight, Free first, Speed first and Cheapest first (a
|
|
// group's). While a provider or group is routed by one, it
|
|
// stays on.
|
|
//
|
|
// It is the first consumer of the gateway's router strategy point (P3 of
|
|
// docs/subsystems/plugin-runtime.md): Apply registers internal/routes'
|
|
// strategies, and off, a pool set to one of them is tried in its listed
|
|
// order and the window offers Smart alone.
|
|
package rotation
|
|
|
|
import (
|
|
"github.com/yetone/magpie/internal/pluginrt"
|
|
"github.com/yetone/magpie/internal/provider"
|
|
"github.com/yetone/magpie/internal/routes"
|
|
)
|
|
|
|
func init() {
|
|
pluginrt.Register(pluginrt.Manifest{
|
|
ID: "rotation", API: "^1", Requires: []string{"providers", "gateway"}, Essential: true,
|
|
Name: "Routing strategies", Sub: "The routings besides Smart: In order, Until used up, In turn, Least used first, Use before expiry, By weight, Free first, Speed first and Cheapest first",
|
|
Opens: "providers",
|
|
One: "1 provider or group routed so", Many: "{n} providers and groups routed so",
|
|
InUse: inUse,
|
|
Parts: []pluginrt.Part{{Slot: "part", Key: "rotation"}},
|
|
Apply: func(c *pluginrt.Ctx) error {
|
|
for name, s := range routes.Builtin {
|
|
c.OnDispose(routes.Register(name, s))
|
|
}
|
|
return nil
|
|
},
|
|
})
|
|
}
|
|
|
|
// inUse counts the providers and groups routed by one of its strategies;
|
|
// a providers.json that can't be read is not known, so it stays on.
|
|
func inUse() (int, error) {
|
|
routings, err := provider.Routings()
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
n := 0
|
|
for _, r := range routings {
|
|
if _, ok := routes.Builtin[r]; ok {
|
|
n++
|
|
}
|
|
}
|
|
return n, nil
|
|
}
|