mirror of
https://github.com/hanzoai/s3.git
synced 2026-11-03 03:07:41 +00:00
hanzoai/s3 was an AGPL-3.0 MinIO fork whose network-copyleft blocks embedding
and reselling as a managed service. Replace it wholesale with a fork of
SeaweedFS (github.com/seaweedfs/seaweedfs, Apache-2.0, Go) which ships a
built-in S3 gateway + Filer.
- License: AGPL-3.0 -> Apache-2.0 (upstream LICENSE kept verbatim, incl.
"Copyright 2025 Chris Lu"); NOTICE added crediting SeaweedFS. No AGPL/BUSL/
SSPL/GPL or enterprise ("ee") files remain.
- Module: go.mod path set to github.com/hanzoai/s3 with a self-replace
(replace github.com/seaweedfs/seaweedfs => ./) so the ~1800 internal Go files
keep their upstream import paths with zero churn. Internal identifiers and
import paths are intentionally NOT renamed.
- CLI rebrand: the binary is built as `s3` (was `weed`); root usage, per-command
help/usage/flag strings, shell autocomplete program name, and the product name
in CLI output now read "Hanzo S3" / `s3`. Users never see `weed`.
(e.g. `s3 server`, `s3 filer`, `s3 master`, `s3 volume`, `s3 s3`, `s3 mount`.)
- Build: `make` (or `go build -o s3 ./weed`) builds the `s3` binary green;
`cmd/weed-db` and `cmd/weed-sql` also build; `go vet ./weed/command/` clean.
- README/LLM.md rewritten for Hanzo S3; AGENTS.md/CLAUDE.md symlinks preserved.
- Dropped a 33MB prebuilt Mach-O `stress` binary upstream had committed; `.gitignore`
updated to ignore the `s3` build output.
210 lines
5.6 KiB
Bash
Executable File
210 lines
5.6 KiB
Bash
Executable File
#!/bin/bash
|
||
|
||
# Test RDMA Connection Pooling Mechanism
|
||
# Demonstrates connection reuse and pool management
|
||
|
||
set -e
|
||
|
||
echo "๐ Testing RDMA Connection Pooling Mechanism"
|
||
echo "============================================"
|
||
|
||
# Colors
|
||
GREEN='\033[0;32m'
|
||
YELLOW='\033[1;33m'
|
||
BLUE='\033[0;34m'
|
||
PURPLE='\033[0;35m'
|
||
NC='\033[0m'
|
||
|
||
echo -e "\n${BLUE}๐งช Testing Connection Pool Logic${NC}"
|
||
echo "--------------------------------"
|
||
|
||
# Test the pool implementation by building a simple test
|
||
cat > /tmp/pool_test.go << 'EOF'
|
||
package main
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
"time"
|
||
)
|
||
|
||
// Simulate the connection pool behavior
|
||
type PooledConnection struct {
|
||
ID string
|
||
lastUsed time.Time
|
||
inUse bool
|
||
created time.Time
|
||
}
|
||
|
||
type ConnectionPool struct {
|
||
connections []*PooledConnection
|
||
maxConnections int
|
||
maxIdleTime time.Duration
|
||
}
|
||
|
||
func NewConnectionPool(maxConnections int, maxIdleTime time.Duration) *ConnectionPool {
|
||
return &ConnectionPool{
|
||
connections: make([]*PooledConnection, 0, maxConnections),
|
||
maxConnections: maxConnections,
|
||
maxIdleTime: maxIdleTime,
|
||
}
|
||
}
|
||
|
||
func (p *ConnectionPool) getConnection() (*PooledConnection, error) {
|
||
// Look for available connection
|
||
for _, conn := range p.connections {
|
||
if !conn.inUse && time.Since(conn.lastUsed) < p.maxIdleTime {
|
||
conn.inUse = true
|
||
conn.lastUsed = time.Now()
|
||
fmt.Printf("๐ Reusing connection: %s (age: %v)\n", conn.ID, time.Since(conn.created))
|
||
return conn, nil
|
||
}
|
||
}
|
||
|
||
// Create new connection if under limit
|
||
if len(p.connections) < p.maxConnections {
|
||
conn := &PooledConnection{
|
||
ID: fmt.Sprintf("conn-%d-%d", len(p.connections), time.Now().Unix()),
|
||
lastUsed: time.Now(),
|
||
inUse: true,
|
||
created: time.Now(),
|
||
}
|
||
p.connections = append(p.connections, conn)
|
||
fmt.Printf("๐ Created new connection: %s (pool size: %d)\n", conn.ID, len(p.connections))
|
||
return conn, nil
|
||
}
|
||
|
||
return nil, fmt.Errorf("pool exhausted (max: %d)", p.maxConnections)
|
||
}
|
||
|
||
func (p *ConnectionPool) releaseConnection(conn *PooledConnection) {
|
||
conn.inUse = false
|
||
conn.lastUsed = time.Now()
|
||
fmt.Printf("๐ Released connection: %s\n", conn.ID)
|
||
}
|
||
|
||
func (p *ConnectionPool) cleanup() {
|
||
now := time.Now()
|
||
activeConnections := make([]*PooledConnection, 0, len(p.connections))
|
||
|
||
for _, conn := range p.connections {
|
||
if conn.inUse || now.Sub(conn.lastUsed) < p.maxIdleTime {
|
||
activeConnections = append(activeConnections, conn)
|
||
} else {
|
||
fmt.Printf("๐งน Cleaned up idle connection: %s (idle: %v)\n", conn.ID, now.Sub(conn.lastUsed))
|
||
}
|
||
}
|
||
|
||
p.connections = activeConnections
|
||
}
|
||
|
||
func (p *ConnectionPool) getStats() (int, int) {
|
||
total := len(p.connections)
|
||
inUse := 0
|
||
for _, conn := range p.connections {
|
||
if conn.inUse {
|
||
inUse++
|
||
}
|
||
}
|
||
return total, inUse
|
||
}
|
||
|
||
func main() {
|
||
fmt.Println("๐ Connection Pool Test Starting...")
|
||
|
||
// Create pool with small limits for testing
|
||
pool := NewConnectionPool(3, 2*time.Second)
|
||
|
||
fmt.Println("\n1. Testing connection creation and reuse:")
|
||
|
||
// Get multiple connections
|
||
conns := make([]*PooledConnection, 0)
|
||
for i := 0; i < 5; i++ {
|
||
conn, err := pool.getConnection()
|
||
if err != nil {
|
||
fmt.Printf("โ Error getting connection %d: %v\n", i+1, err)
|
||
continue
|
||
}
|
||
conns = append(conns, conn)
|
||
|
||
// Simulate work
|
||
time.Sleep(100 * time.Millisecond)
|
||
}
|
||
|
||
total, inUse := pool.getStats()
|
||
fmt.Printf("\n๐ Pool stats: %d total connections, %d in use\n", total, inUse)
|
||
|
||
fmt.Println("\n2. Testing connection release and reuse:")
|
||
|
||
// Release some connections
|
||
for i := 0; i < 2; i++ {
|
||
if i < len(conns) {
|
||
pool.releaseConnection(conns[i])
|
||
}
|
||
}
|
||
|
||
// Try to get new connections (should reuse)
|
||
for i := 0; i < 2; i++ {
|
||
conn, err := pool.getConnection()
|
||
if err != nil {
|
||
fmt.Printf("โ Error getting reused connection: %v\n", err)
|
||
} else {
|
||
pool.releaseConnection(conn)
|
||
}
|
||
}
|
||
|
||
fmt.Println("\n3. Testing cleanup of idle connections:")
|
||
|
||
// Wait for connections to become idle
|
||
fmt.Println("โฑ๏ธ Waiting for connections to become idle...")
|
||
time.Sleep(3 * time.Second)
|
||
|
||
// Cleanup
|
||
pool.cleanup()
|
||
|
||
total, inUse = pool.getStats()
|
||
fmt.Printf("๐ Pool stats after cleanup: %d total connections, %d in use\n", total, inUse)
|
||
|
||
fmt.Println("\nโ
Connection pool test completed successfully!")
|
||
fmt.Println("\n๐ฏ Key benefits demonstrated:")
|
||
fmt.Println(" โข Connection reuse eliminates setup cost")
|
||
fmt.Println(" โข Pool size limits prevent resource exhaustion")
|
||
fmt.Println(" โข Automatic cleanup prevents memory leaks")
|
||
fmt.Println(" โข Idle timeout ensures fresh connections")
|
||
}
|
||
EOF
|
||
|
||
echo "๐ Created connection pool test program"
|
||
|
||
echo -e "\n${GREEN}๐ Running connection pool simulation${NC}"
|
||
echo "------------------------------------"
|
||
|
||
# Run the test
|
||
cd /tmp && go run pool_test.go
|
||
|
||
echo -e "\n${YELLOW}๐ Performance Impact Analysis${NC}"
|
||
echo "------------------------------"
|
||
|
||
echo "Without connection pooling:"
|
||
echo " โข Each request: 100ms setup + 1ms transfer = 101ms"
|
||
echo " โข 10 requests: 10 ร 101ms = 1010ms"
|
||
|
||
echo ""
|
||
echo "With connection pooling:"
|
||
echo " โข First request: 100ms setup + 1ms transfer = 101ms"
|
||
echo " โข Next 9 requests: 0.1ms reuse + 1ms transfer = 1.1ms each"
|
||
echo " โข 10 requests: 101ms + (9 ร 1.1ms) = 111ms"
|
||
|
||
echo ""
|
||
echo -e "${GREEN}๐ฅ Performance improvement: 1010ms โ 111ms = 9x faster!${NC}"
|
||
|
||
echo -e "\n${PURPLE}๐ก Real-world scaling benefits:${NC}"
|
||
echo "โข 100 requests: 100x faster with pooling"
|
||
echo "โข 1000 requests: 1000x faster with pooling"
|
||
echo "โข Connection pool amortizes setup cost across many operations"
|
||
|
||
# Cleanup
|
||
rm -f /tmp/pool_test.go
|
||
|
||
echo -e "\n${GREEN}โ
Connection pooling test completed!${NC}"
|