mirror of
https://github.com/pacnpal/markov-discord.git
synced 2025-12-20 03:01:04 -05:00
feat: Implement configuration management and logging for Markov bot
- Added AppConfig class to manage application configuration with environment variable support. - Introduced JSON5 support for configuration files, allowing both .json and .json5 extensions. - Implemented logging using Pino with pretty-printing for better readability. - Created a MarkovStore class for efficient storage and retrieval of Markov chains with O(1) sampling. - Developed a WorkerPool class to manage worker threads for parallel processing of tasks. - Added methods for building chains, generating responses, and handling task submissions in the worker pool. - Included validation for configuration using class-validator to ensure correctness. - Established a clear structure for configuration, logging, and Markov chain management.
This commit is contained in:
57
.env.example
Normal file
57
.env.example
Normal file
@@ -0,0 +1,57 @@
|
||||
# === DISCORD BOT SETTINGS ===
|
||||
TOKEN=YOUR_BOT_TOKEN_HERE
|
||||
MESSAGE_COMMAND_PREFIX=!mark
|
||||
SLASH_COMMAND_NAME=mark
|
||||
ACTIVITY=!mark help for help
|
||||
OWNER_IDS=YOUR_USER_ID_HERE
|
||||
# USER_ROLE_IDS=role1,role2,role3 # Uncomment and set specific role IDs if needed
|
||||
# RESPONSE_CHANNEL_IDS=channel1,channel2 # Uncomment to limit response channels
|
||||
|
||||
# === MARKOV CHAIN SETTINGS ===
|
||||
STATE_SIZE=2
|
||||
MAX_TRIES=2000
|
||||
MIN_SCORE=10
|
||||
|
||||
# === HIGH PERFORMANCE OPTIMIZATIONS FOR LARGE SERVERS ===
|
||||
|
||||
# Enable optimized MarkovStore with O(1) alias method sampling
|
||||
# This provides massive performance improvements over traditional approach
|
||||
ENABLE_MARKOV_STORE=true
|
||||
|
||||
# Enable worker thread pool for CPU-intensive operations
|
||||
# Offloads chain building and generation to background threads
|
||||
ENABLE_WORKER_POOL=true
|
||||
|
||||
# Number of worker threads (recommended: CPU cores or 4, whichever is smaller)
|
||||
WORKER_POOL_SIZE=4
|
||||
|
||||
# Enable batch processing optimizations
|
||||
ENABLE_BATCH_OPTIMIZATION=true
|
||||
|
||||
# Large batch size for maximum efficiency (25x larger than default)
|
||||
# Higher values = more memory usage but much better performance for large servers
|
||||
BATCH_SIZE=5000
|
||||
|
||||
# Memory limit for chain caching in MB (higher = more cached chains = faster responses)
|
||||
CHAIN_CACHE_MEMORY_LIMIT=512
|
||||
|
||||
# Chain save debounce delay in milliseconds (lower = more frequent saves)
|
||||
CHAIN_SAVE_DEBOUNCE_MS=3000
|
||||
|
||||
# === OPTIMIZATION ROLLOUT ===
|
||||
|
||||
# Percentage of guilds to enable optimizations for (0-100)
|
||||
# Set to 100 to enable ALL optimizations for ALL servers
|
||||
OPTIMIZATION_ROLLOUT_PERCENTAGE=100
|
||||
|
||||
# Force-enable optimizations for specific large server IDs (comma-separated)
|
||||
# Example: OPTIMIZATION_FORCE_GUILD_IDS=123456789012345678,987654321098765432
|
||||
OPTIMIZATION_FORCE_GUILD_IDS=
|
||||
|
||||
# Enable performance monitoring and metrics collection
|
||||
ENABLE_PERFORMANCE_MONITORING=true
|
||||
|
||||
# === DEVELOPMENT SETTINGS ===
|
||||
# DEV_GUILD_ID= # Leave empty for production
|
||||
TZ=UTC
|
||||
LOG_LEVEL=info # Options: silent, error, warn, info, debug, trace
|
||||
Reference in New Issue
Block a user