budget

package
v2.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Budget

type Budget struct {
	// contains filtered or unexported fields
}

Budget manages connection limits per provider to prevent exceeding NNTP server quotas

func New

func New() *Budget

New creates a new connection budget manager

func (*Budget) AcquireConnection

func (cb *Budget) AcquireConnection(providerID string) error

AcquireConnection attempts to acquire a connection slot for the provider

func (*Budget) CanAcquireConnection

func (cb *Budget) CanAcquireConnection(providerID string) bool

CanAcquireConnection checks if a new connection can be acquired for the provider

func (*Budget) CanMigrateConnection

func (cb *Budget) CanMigrateConnection(providerID string) bool

CanMigrateConnection checks if we can create a new connection during migration This considers both current usage and temporary migration overhead

func (*Budget) GetAvailableSlots

func (cb *Budget) GetAvailableSlots(providerID string) int

GetAvailableSlots returns how many more connections can be created for the provider

func (*Budget) GetProviderStats

func (cb *Budget) GetProviderStats() map[string]Stats

GetProviderStats returns detailed statistics for all providers

func (*Budget) GetProviderUsage

func (cb *Budget) GetProviderUsage(providerID string) (current, limit int, exists bool)

GetProviderUsage returns current usage for a provider

func (*Budget) GetTotalBudget

func (cb *Budget) GetTotalBudget() (totalUsed, totalLimit int)

GetTotalBudget returns the total connection budget across all providers

func (*Budget) ReleaseConnection

func (cb *Budget) ReleaseConnection(providerID string)

ReleaseConnection releases a connection slot for the provider

func (*Budget) RemoveProvider

func (cb *Budget) RemoveProvider(providerID string)

RemoveProvider removes a provider from budget tracking

func (*Budget) SetProviderLimit

func (cb *Budget) SetProviderLimit(providerID string, maxConnections int)

SetProviderLimit sets the maximum connections allowed for a provider

type Stats

type Stats struct {
	ProviderID         string  `json:"provider_id"`
	CurrentConnections int     `json:"current_connections"`
	MaxConnections     int     `json:"max_connections"`
	AvailableSlots     int     `json:"available_slots"`
	UtilizationPercent float64 `json:"utilization_percent"`
}

Stats contains statistics for a provider's connection budget

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL