pool

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultStatBatchSize = 100

DefaultStatBatchSize is the fallback number of message-IDs per StatMany call when no batch size is configured.

Variables

This section is empty.

Functions

func ProviderKey added in v0.0.30

func ProviderKey(s config.ServerConfig) string

ProviderKey returns the canonical provider key for a server config.

func ServerConfigChanged added in v0.0.30

func ServerConfigChanged(a, b config.ServerConfig) bool

ServerConfigChanged returns true if any provider-relevant fields differ between two server configs. This is the canonical predicate for "did this provider's pool-affecting state change".

func StatMissing added in v0.0.31

func StatMissing(ctx context.Context, c NNTPClient, ids []string, batchSize int) (map[string]struct{}, error)

StatMissing STATs ids in chunks of batchSize (<=0 -> DefaultStatBatchSize) and returns the message-IDs NOT confirmed present. Any per-ID error counts as missing (preserves the "error => repost" semantics of the previous one-by-one checks). Returns ctx.Err() if the sweep was cancelled.

Types

type Manager

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

Manager manages NNTP connection pools throughout the application lifecycle, enabling proper metrics accumulation. Use dependency injection to pass this around. Supports separate pools for posting (upload) and article verification (verify).

func New

func New(cfg *config.ConfigData) (*Manager, error)

New creates a new connection pool manager with the given configuration. Creates separate pools for upload and verification.

func (*Manager) Close

func (m *Manager) Close() error

Close gracefully shuts down the connection pool manager. This should be called during application shutdown.

func (*Manager) GetCheckPool added in v0.0.29

func (m *Manager) GetCheckPool() NNTPClient

GetCheckPool is a deprecated alias for GetVerifyPool.

func (*Manager) GetMetrics

func (m *Manager) GetMetrics() (nntppool.ClientStats, error)

GetMetrics returns the current metrics from the connection pool.

func (*Manager) GetPool

func (m *Manager) GetPool() NNTPClient

GetPool is a deprecated alias for GetUploadPool.

func (*Manager) GetUploadPool added in v0.0.29

func (m *Manager) GetUploadPool() NNTPClient

GetUploadPool returns the NNTP connection pool for posting articles.

func (*Manager) GetVerifyPool added in v0.0.29

func (m *Manager) GetVerifyPool() NNTPClient

GetVerifyPool returns the NNTP connection pool for article verification. Returns verify-role servers if configured, otherwise falls back to upload pool.

func (*Manager) IsClosed

func (m *Manager) IsClosed() bool

IsClosed returns true if the manager has been closed.

func (*Manager) UpdateConfig

func (m *Manager) UpdateConfig(newCfg *config.ConfigData) error

UpdateConfig updates the connection pools with a new configuration. Uses AddProvider/RemoveProvider for incremental updates instead of destroying pools.

type NNTPClient added in v0.0.29

type NNTPClient interface {
	PostYenc(ctx context.Context, headers nntppool.PostHeaders, body io.Reader, meta rapidyenc.Meta) (*nntppool.PostResult, error)
	Stat(ctx context.Context, messageID string) (*nntppool.StatResult, error)
	StatMany(ctx context.Context, messageIDs []string, opts nntppool.StatManyOptions) <-chan nntppool.StatManyResult
	Stats() nntppool.ClientStats
	AddProvider(p nntppool.Provider) error
	RemoveProvider(name string) error
	Close() error
}

NNTPClient defines the interface for NNTP connection pool operations. This wraps *nntppool.Client to enable testing with mocks.

type PoolManager added in v0.0.29

type PoolManager interface {
	GetUploadPool() NNTPClient
	GetVerifyPool() NNTPClient
	GetPool() NNTPClient      // Deprecated: use GetUploadPool
	GetCheckPool() NNTPClient // Deprecated: use GetVerifyPool
}

PoolManager defines the interface for connection pool management. This interface is implemented by Manager and can be mocked for testing.

Jump to

Keyboard shortcuts

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