mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-06-22 17:47:51 +08:00
- Added a Go scheduler plugin demonstrating CLIProxyAPI capabilities, such as `plugin.register`, `plugin.reconfigure`, and `scheduler.pick`. - Implemented methods for plugin configuration, built-in scheduler delegation (`fill-first`, `round-robin`), dynamic candidate selection, and error handling. - Extended `pluginhost` with scheduler handling, candidate normalization, and fallback mechanisms. - Included examples, tests, and detailed documentation for scheduler usage and implementation.
Scheduler Plugin
This plugin demonstrates the CLIProxyAPI C ABI scheduler capability from Go.
It implements:
plugin.registerplugin.reconfigurescheduler.pick
The plugin can select a configured auth ID, delegate routing to a built-in scheduler, or reject scheduler picks.
Configuration
Add the plugin under plugins.configs:
plugins:
configs:
scheduler:
enabled: true
priority: 1
auth_id: ""
delegate: ""
deny: false
Fields:
auth_id: selects this auth ID when it appears in the scheduler candidates.delegate: delegates selection to a built-in scheduler. Supported values are"",fill-first, andround-robin.deny: returns a scheduler error when set totrue.
Behavior:
- When
denyistrue, the plugin returns an error envelope with codescheduler_denied. - When
delegateisfill-firstorround-robin, the plugin returnsDelegateBuiltinand marks the pick as handled. - When
delegateis any other non-empty value, the plugin leaves the pick unhandled. - When
delegateis empty andauth_idexists in the candidates, the plugin returns that auth ID and marks the pick as handled. - When no rule matches, the plugin leaves the pick unhandled.
Build
From this directory:
cd go
go build -buildmode=c-shared -o /tmp/cliproxy-scheduler-plugin.so .
rm -f /tmp/cliproxy-scheduler-plugin.so /tmp/cliproxy-scheduler-plugin.h