mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-11-16 14:49:40 +08:00
71 lines
2.8 KiB
Go
71 lines
2.8 KiB
Go
package pluginhost
|
|
|
|
import (
|
|
"context"
|
|
|
|
internalpluginhost "github.com/router-for-me/CLIProxyAPI/v8/internal/pluginhost"
|
|
"github.com/router-for-me/CLIProxyAPI/v8/sdk/pluginapi"
|
|
)
|
|
|
|
// RegisteredQuotaProviderInfo describes quota capabilities exposed to embedders.
|
|
type RegisteredQuotaProviderInfo = internalpluginhost.RegisteredQuotaProviderInfo
|
|
|
|
// QuotaProviders lists active quota providers using the request context.
|
|
func (h *Host) QuotaProviders(ctx context.Context) []RegisteredQuotaProviderInfo {
|
|
if h == nil || h.inner == nil {
|
|
return nil
|
|
}
|
|
return h.inner.QuotaProviders(ctx)
|
|
}
|
|
|
|
// QuotaProviderPluginIDs maps normalized provider keys to the selected active quota plugin.
|
|
// Selection preserves host precedence and excludes plugins fused during capability discovery.
|
|
func (h *Host) QuotaProviderPluginIDs(ctx context.Context) map[string]string {
|
|
if h == nil || h.inner == nil {
|
|
return nil
|
|
}
|
|
return h.inner.QuotaProviderPluginIDs(ctx)
|
|
}
|
|
|
|
// HasQuotaProviderContext reports whether a provider handles credential quotas.
|
|
func (h *Host) HasQuotaProviderContext(ctx context.Context, provider string) bool {
|
|
return h != nil && h.inner != nil && h.inner.HasQuotaProviderContext(ctx, provider)
|
|
}
|
|
|
|
// HasQuotaProviderForPlugin reports whether a plugin exposes quota operations.
|
|
func (h *Host) HasQuotaProviderForPlugin(pluginID string) bool {
|
|
return h != nil && h.inner != nil && h.inner.HasQuotaProviderForPlugin(pluginID)
|
|
}
|
|
|
|
// FetchQuota invokes a quota provider through the public embedding API.
|
|
func (h *Host) FetchQuota(ctx context.Context, req pluginapi.QuotaFetchRequest) (pluginapi.QuotaFetchResponse, bool, error) {
|
|
if h == nil || h.inner == nil {
|
|
return pluginapi.QuotaFetchResponse{}, false, nil
|
|
}
|
|
return h.inner.FetchQuota(ctx, req)
|
|
}
|
|
|
|
// FetchQuotaByPlugin invokes a quota provider through the public embedding API.
|
|
func (h *Host) FetchQuotaByPlugin(ctx context.Context, pluginID string, req pluginapi.QuotaFetchRequest) (pluginapi.QuotaFetchResponse, bool, error) {
|
|
if h == nil || h.inner == nil {
|
|
return pluginapi.QuotaFetchResponse{}, false, nil
|
|
}
|
|
return h.inner.FetchQuotaByPlugin(ctx, pluginID, req)
|
|
}
|
|
|
|
// ResetQuota invokes a quota provider through the public embedding API.
|
|
func (h *Host) ResetQuota(ctx context.Context, req pluginapi.QuotaResetRequest) (pluginapi.QuotaResetResponse, bool, error) {
|
|
if h == nil || h.inner == nil {
|
|
return pluginapi.QuotaResetResponse{}, false, nil
|
|
}
|
|
return h.inner.ResetQuota(ctx, req)
|
|
}
|
|
|
|
// ResetQuotaByPlugin invokes a quota provider through the public embedding API.
|
|
func (h *Host) ResetQuotaByPlugin(ctx context.Context, pluginID string, req pluginapi.QuotaResetRequest) (pluginapi.QuotaResetResponse, bool, error) {
|
|
if h == nil || h.inner == nil {
|
|
return pluginapi.QuotaResetResponse{}, false, nil
|
|
}
|
|
return h.inner.ResetQuotaByPlugin(ctx, pluginID, req)
|
|
}
|