performance

package
v1.0.74 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionPool

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

ConnectionPool manages a pool of DynamoDB connections

func NewConnectionPool

func NewConnectionPool(ctx context.Context, cfg *ConnectionPoolConfig) (*ConnectionPool, error)

NewConnectionPool creates a new connection pool with the given configuration

func (*ConnectionPool) Close

func (p *ConnectionPool) Close() error

Close closes the connection pool and all clients

func (*ConnectionPool) GetClient

func (p *ConnectionPool) GetClient(ctx context.Context) (*dynamodb.Client, error)

GetClient retrieves a client from the pool

func (*ConnectionPool) GetMetrics

func (p *ConnectionPool) GetMetrics() *PoolMetrics

GetMetrics returns current pool metrics

func (*ConnectionPool) OptimizeForWorkload

func (p *ConnectionPool) OptimizeForWorkload(workloadType string) error

OptimizeForWorkload adjusts pool configuration based on workload characteristics

func (*ConnectionPool) PoolStats

func (p *ConnectionPool) PoolStats() map[string]interface{}

PoolStats returns formatted statistics about the pool

func (*ConnectionPool) ReturnClient

func (p *ConnectionPool) ReturnClient(client *dynamodb.Client)

ReturnClient returns a client to the pool

type ConnectionPoolConfig

type ConnectionPoolConfig struct {
	Region              string        `json:"region"`
	Endpoint            string        `json:"endpoint,omitempty"`
	MaxConnections      int           `json:"max_connections"`
	MinConnections      int           `json:"min_connections"`
	MaxIdleTime         time.Duration `json:"max_idle_time"`
	ConnectionTimeout   time.Duration `json:"connection_timeout"`
	MaxRetries          int           `json:"max_retries"`
	RetryDelay          time.Duration `json:"retry_delay"`
	BackoffMultiplier   float64       `json:"backoff_multiplier"`
	HealthCheckInterval time.Duration `json:"health_check_interval"`
	HealthCheckTimeout  time.Duration `json:"health_check_timeout"`
	EnableMetrics       bool          `json:"enable_metrics"`
}

ConnectionPoolConfig holds configuration for DynamoDB connection pooling

func DefaultConnectionPoolConfig

func DefaultConnectionPoolConfig() *ConnectionPoolConfig

DefaultConnectionPoolConfig returns a default configuration optimized for DynamORM

func HighThroughputConnectionPoolConfig

func HighThroughputConnectionPoolConfig() *ConnectionPoolConfig

HighThroughputConnectionPoolConfig returns configuration for high-throughput scenarios

func LowLatencyConnectionPoolConfig

func LowLatencyConnectionPoolConfig() *ConnectionPoolConfig

LowLatencyConnectionPoolConfig returns configuration optimized for low latency

func ProductionConnectionPoolConfig

func ProductionConnectionPoolConfig() *ConnectionPoolConfig

ProductionConnectionPoolConfig returns configuration optimized for production workloads

type DynamORMPool

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

DynamORMPool wraps DynamORM with connection pooling for improved performance Memory optimized: 56 → 24 bytes (32 bytes saved)

func NewDynamORMPool

func NewDynamORMPool(ctx context.Context, config *PooledDynamORMConfig) (*DynamORMPool, error)

NewDynamORMPool creates a new pooled DynamORM instance

func (*DynamORMPool) CleanupIdleSessions

func (p *DynamORMPool) CleanupIdleSessions(maxIdleTime time.Duration) int

CleanupIdleSessions removes sessions that have been idle for too long

func (*DynamORMPool) Close

func (p *DynamORMPool) Close() error

Close closes the DynamORM pool and all sessions

func (*DynamORMPool) ExecuteWithClient

func (p *DynamORMPool) ExecuteWithClient(ctx context.Context, tableName string, fn func(*dynamodb.Client) error) error

ExecuteWithClient executes a function with a pooled DynamoDB client

func (*DynamORMPool) GetClient

func (p *DynamORMPool) GetClient(ctx context.Context, tableName string) (*dynamodb.Client, func(), error)

GetClient returns a DynamoDB client for direct operations

func (*DynamORMPool) GetPoolStats

func (p *DynamORMPool) GetPoolStats() map[string]interface{}

GetPoolStats returns statistics about the connection pool

func (*DynamORMPool) GetSession

func (p *DynamORMPool) GetSession(ctx context.Context, tableName string) (*PooledSession, error)

GetSession returns a DynamORM session, creating one if necessary

func (*DynamORMPool) OptimizeForWorkload

func (p *DynamORMPool) OptimizeForWorkload(workloadType string) error

OptimizeForWorkload optimizes the pool for a specific workload type

func (*DynamORMPool) ReturnSession

func (p *DynamORMPool) ReturnSession(session *PooledSession)

ReturnSession returns a session to the pool

func (*DynamORMPool) SessionStats

func (p *DynamORMPool) SessionStats() map[string]interface{}

SessionStats returns statistics about active sessions

func (*DynamORMPool) StartMaintenanceRoutine

func (p *DynamORMPool) StartMaintenanceRoutine(ctx context.Context, interval time.Duration)

StartMaintenanceRoutine starts a background routine for pool maintenance

func (*DynamORMPool) WithMetrics added in v1.0.58

func (p *DynamORMPool) WithMetrics(metrics lift.MetricsCollector) *DynamORMPool

WithMetrics attaches a metrics collector to the pool (optional).

type PoolMetrics

type PoolMetrics struct {
	LastHealthCheck      time.Time     `json:"last_health_check"`
	ActiveConnections    int64         `json:"active_connections"`
	IdleConnections      int64         `json:"idle_connections"`
	TotalRequests        int64         `json:"total_requests"`
	FailedRequests       int64         `json:"failed_requests"`
	AverageWaitTime      time.Duration `json:"average_wait_time"`
	ConnectionsCreated   int64         `json:"connections_created"`
	ConnectionsDestroyed int64         `json:"connections_destroyed"`
	HealthChecksPassed   int64         `json:"health_checks_passed"`
	HealthChecksFailed   int64         `json:"health_checks_failed"`
	// contains filtered or unexported fields
}

PoolMetrics tracks connection pool performance

type PooledDynamORMConfig

type PooledDynamORMConfig struct {
	ConnectionPoolConfig *ConnectionPoolConfig `json:"connection_pool_config"`
	DefaultTableName     string                `json:"default_table_name"`
	MetricsPrefix        string                `json:"metrics_prefix"`
	DefaultTimeout       time.Duration         `json:"default_timeout"`
	BatchFlushInterval   time.Duration         `json:"batch_flush_interval"`
	CacheTTL             time.Duration         `json:"cache_ttl"`
	BatchSize            int                   `json:"batch_size"`
	CacheSize            int                   `json:"cache_size"`
	EnableBatching       bool                  `json:"enable_batching"`
	EnableCaching        bool                  `json:"enable_caching"`
	EnableMetrics        bool                  `json:"enable_metrics"`
}

PooledDynamORMConfig holds configuration for pooled DynamORM operations Memory optimized: 104 → 88 bytes (16 bytes saved)

func DefaultPooledDynamORMConfig

func DefaultPooledDynamORMConfig() *PooledDynamORMConfig

DefaultPooledDynamORMConfig returns a default configuration for pooled DynamORM

type PooledSession

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

PooledSession represents a DynamORM session with pooled connections

Jump to

Keyboard shortcuts

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