warden

command module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

README ยถ

Warden

๐ŸŒ Language / ่ฏญ่จ€: English | ไธญๆ–‡ | Franรงais | Italiano | ๆ—ฅๆœฌ่ชž | Deutsch | ํ•œ๊ตญ์–ด

A high-performance AllowList user data service that supports data synchronization and merging from local and remote configuration sources.

Warden

Warden (The Gatekeeper) โ€” The guardian of the Stargate who decides who may pass and who will be denied. Just as the Warden of Stargate guards the Stargate, Warden guards your allowlist, ensuring only authorized users can pass through.

๐Ÿ“‹ Project Overview

Warden is a lightweight HTTP API service developed in Go, primarily used for providing and managing allowlist user data (phone numbers and email addresses). The service supports fetching data from local configuration files and remote APIs, and provides multiple data merging strategies to ensure data real-time performance and reliability.

โœจ Core Features

  • ๐Ÿš€ High Performance: Supports 5000+ requests per second with an average latency of 21ms
  • ๐Ÿ”„ Multiple Data Sources: Supports both local configuration files and remote APIs
  • ๐ŸŽฏ Flexible Strategies: Provides 6 data merging modes (remote-first, local-first, remote-only, local-only, etc.)
  • โฐ Scheduled Updates: Scheduled tasks based on Redis distributed locks for automatic data synchronization
  • ๐Ÿ“ฆ Containerized Deployment: Complete Docker support, ready to use out of the box
  • ๐Ÿ“Š Structured Logging: Uses zerolog to provide detailed access logs and error logs
  • ๐Ÿ”’ Distributed Locks: Uses Redis to ensure scheduled tasks don't execute repeatedly in distributed environments
  • ๐ŸŒ Multi-language Support: Supports 7 languages (English, Chinese, French, Italian, Japanese, German, Korean) with automatic language detection

๐Ÿ—๏ธ Architecture Design

Warden uses a layered architecture design, including HTTP layer, business layer, and infrastructure layer. The system supports multiple data sources, multi-level caching, and distributed locking mechanisms.

For detailed architecture documentation, please refer to: Architecture Design Documentation

๐Ÿ“ฆ Installation and Running

๐Ÿ’ก Quick Start: Want to quickly experience Warden? Check out our Quick Start Examples:

Prerequisites
  • Go 1.25+ (refer to go.mod)
  • Redis (optional, for distributed locks and caching - disabled by default in ONLY_LOCAL mode)
  • Docker (optional, for containerized deployment)
Quick Start
  1. Clone the project
git clone <repository-url>
cd warden
  1. Install dependencies
go mod download
  1. Configure local data file Create a data.json file (refer to data.example.json):
[
    {
        "phone": "13800138000",
        "mail": "admin@example.com"
    }
]
  1. Run the service
go run main.go

For detailed configuration and deployment instructions, please refer to:

โš™๏ธ Configuration

Warden supports multiple configuration methods: command line arguments, environment variables, and configuration files. The system provides 6 data merging modes with flexible configuration strategies.

For detailed configuration documentation, please refer to: Configuration Documentation

๐Ÿ“ก API Documentation

Warden provides a complete RESTful API with support for user list queries, pagination, health checks, and more. The project also provides OpenAPI 3.0 specification documentation.

For detailed API documentation, please refer to: API Documentation

OpenAPI specification file: openapi.yaml

๐ŸŒ Multi-language Support

Warden supports complete internationalization (i18N) functionality. All API responses, error messages, and logs support internationalization.

Supported Languages
  • ๐Ÿ‡บ๐Ÿ‡ธ English (en) - Default
  • ๐Ÿ‡จ๐Ÿ‡ณ Chinese (zh)
  • ๐Ÿ‡ซ๐Ÿ‡ท French (fr)
  • ๐Ÿ‡ฎ๐Ÿ‡น Italian (it)
  • ๐Ÿ‡ฏ๐Ÿ‡ต Japanese (ja)
  • ๐Ÿ‡ฉ๐Ÿ‡ช German (de)
  • ๐Ÿ‡ฐ๐Ÿ‡ท Korean (ko)
Language Detection

Warden supports two language detection methods with the following priority:

  1. Query Parameter: Specify language via ?lang=zh
  2. Accept-Language Header: Automatically detect browser language preference
  3. Default Language: English if not specified
Usage Examples
# Specify Chinese via query parameter
curl -H "X-API-Key: your-key" "http://localhost:8081/?lang=zh"

# Auto-detect via Accept-Language header
curl -H "X-API-Key: your-key" -H "Accept-Language: zh-CN,zh;q=0.9" "http://localhost:8081/"

# Use Japanese
curl -H "X-API-Key: your-key" "http://localhost:8081/?lang=ja"

For detailed multi-language documentation, please refer to: Multi-language Documentation

๐Ÿณ Docker Deployment

Warden supports complete Docker and Docker Compose deployment, ready to use out of the box.

Use the pre-built image from GitHub Container Registry (GHCR) to get started quickly without local build:

# Pull the latest version image
docker pull ghcr.io/soulteary/warden:latest

# Run container (basic example)
docker run -d \
  -p 8081:8081 \
  -v $(pwd)/data.json:/app/data.json:ro \
  -e PORT=8081 \
  -e REDIS=localhost:6379 \
  -e API_KEY=your-api-key-here \
  ghcr.io/soulteary/warden:latest

๐Ÿ’ก Tip: Using pre-built images allows you to get started quickly without a local build environment. Images are automatically updated to ensure you're using the latest version.

Using Docker Compose

๐Ÿš€ Quick Deployment: Check the Examples Directory for complete Docker Compose configuration examples

For detailed deployment documentation, please refer to: Deployment Documentation

๐Ÿ“Š Performance Metrics

Based on wrk stress test results (30-second test, 16 threads, 100 connections):

Requests/sec:   5038.81
Transfer/sec:   38.96MB
Average Latency: 21.30ms
Max Latency:     226.09ms

๐Ÿ“ Project Structure

warden/
โ”œโ”€โ”€ main.go                 # Program entry point
โ”œโ”€โ”€ data.example.json      # Local data file example
โ”œโ”€โ”€ config.example.yaml    # Configuration file example
โ”œโ”€โ”€ openapi.yaml           # OpenAPI specification file
โ”œโ”€โ”€ go.mod                 # Go module definition
โ”œโ”€โ”€ docker-compose.yml     # Docker Compose configuration
โ”œโ”€โ”€ LICENSE                # License file
โ”œโ”€โ”€ README.*.md            # Multi-language project documents (Chinese/English/French/Italian/Japanese/German/Korean)
โ”œโ”€โ”€ CONTRIBUTING.*.md      # Multi-language contribution guides
โ”œโ”€โ”€ docker/
โ”‚   โ””โ”€โ”€ Dockerfile         # Docker image build file
โ”œโ”€โ”€ docs/                  # Documentation directory (multi-language)
โ”‚   โ”œโ”€โ”€ enUS/              # English documentation
โ”‚   โ””โ”€โ”€ zhCN/              # Chinese documentation
โ”œโ”€โ”€ example/               # Quick start examples
โ”‚   โ”œโ”€โ”€ basic/             # Simple example (local file only)
โ”‚   โ””โ”€โ”€ advanced/          # Advanced example (full features, includes Mock API)
โ”œโ”€โ”€ internal/
โ”‚   โ”œโ”€โ”€ cache/             # Redis cache and lock implementation
โ”‚   โ”œโ”€โ”€ cmd/               # Command line argument parsing
โ”‚   โ”œโ”€โ”€ config/            # Configuration management
โ”‚   โ”œโ”€โ”€ define/            # Constant definitions and data structures
โ”‚   โ”œโ”€โ”€ di/                # Dependency injection
โ”‚   โ”œโ”€โ”€ errors/            # Error handling
โ”‚   โ”œโ”€โ”€ logger/            # Logging initialization
โ”‚   โ”œโ”€โ”€ metrics/           # Metrics collection
โ”‚   โ”œโ”€โ”€ middleware/        # HTTP middleware
โ”‚   โ”œโ”€โ”€ parser/            # Data parser (local/remote)
โ”‚   โ”œโ”€โ”€ router/            # HTTP route handling
โ”‚   โ”œโ”€โ”€ validator/         # Validator
โ”‚   โ””โ”€โ”€ version/           # Version information
โ”œโ”€โ”€ pkg/
โ”‚   โ”œโ”€โ”€ gocron/            # Scheduled task scheduler
โ”‚   โ””โ”€โ”€ warden/            # Warden SDK
โ”œโ”€โ”€ scripts/               # Scripts directory
โ””โ”€โ”€ .github/               # GitHub configuration (CI/CD, Issue/PR templates, etc.)

๐Ÿ”’ Security Features

Warden implements multiple security features, including API authentication, SSRF protection, rate limiting, TLS verification, and more.

For detailed security documentation, please refer to: Security Documentation

๐Ÿ”ง Development Guide

๐Ÿ“š Reference Examples: Check the Examples Directory for complete example code and configurations for different usage scenarios.

For detailed development documentation, please refer to: Development Documentation

Code Standards

The project follows Go official code standards and best practices. For detailed standards, please refer to:

๐Ÿ“„ License

See the LICENSE file for details.

๐Ÿค Contributing

Welcome to submit Issues and Pull Requests!

๐Ÿ“ž Contact

For questions or suggestions, please contact via Issues.


Version: The program displays version, build time, and code version on startup (via warden --version or startup logs)

Documentation ยถ

Overview ยถ

Package main is the entry point of the application. Provides HTTP server, cache management, scheduled task scheduling and other functionality.

Directories ยถ

Path Synopsis
internal
cache
Package cache provides user data caching functionality.
Package cache provides user data caching functionality.
cmd
Package cmd provides command-line argument parsing and configuration management functionality.
Package cmd provides command-line argument parsing and configuration management functionality.
config
Package config provides configuration file loading and management functionality.
Package config provides configuration file loading and management functionality.
define
Package define defines constants and data structures in the application.
Package define defines constants and data structures in the application.
di
Package di provides dependency injection functionality.
Package di provides dependency injection functionality.
errors
Package errors provides unified error handling functionality.
Package errors provides unified error handling functionality.
i18n
Package i18n provides internationalization support.
Package i18n provides internationalization support.
logger
Package logger provides logging functionality.
Package logger provides logging functionality.
metrics
Package metrics provides Prometheus metrics collection functionality.
Package metrics provides Prometheus metrics collection functionality.
middleware
Package middleware provides HTTP middleware functionality.
Package middleware provides HTTP middleware functionality.
parser
Package parser provides data parsing functionality.
Package parser provides data parsing functionality.
router
Package router provides HTTP routing functionality.
Package router provides HTTP routing functionality.
validator
Package validator provides configuration validation functionality.
Package validator provides configuration validation functionality.
version
Package version provides application version information.
Package version provides application version information.
pkg
gocron
Package gocron : A Golang Job Scheduling Package.
Package gocron : A Golang Job Scheduling Package.
warden
Package warden provides a client SDK for interacting with Warden API.
Package warden provides a client SDK for interacting with Warden API.

Jump to

Keyboard shortcuts

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