mirror of
https://github.com/hanzoai/s3.git
synced 2026-10-30 14:59:09 +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.
124 lines
3.7 KiB
Go
124 lines
3.7 KiB
Go
// Package postgres provides PostgreSQL filer store implementation
|
|
// Migrated from github.com/lib/pq to github.com/jackc/pgx for:
|
|
// - Active development and support
|
|
// - Better performance and PostgreSQL-specific features
|
|
// - Improved error handling (no more panics)
|
|
// - Built-in logging capabilities
|
|
// - Superior SSL certificate support
|
|
package postgres
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/filer"
|
|
"github.com/seaweedfs/seaweedfs/weed/filer/abstract_sql"
|
|
"github.com/seaweedfs/seaweedfs/weed/util"
|
|
)
|
|
|
|
func init() {
|
|
filer.Stores = append(filer.Stores, &PostgresStore{})
|
|
}
|
|
|
|
type PostgresStore struct {
|
|
abstract_sql.AbstractSqlStore
|
|
}
|
|
|
|
func (store *PostgresStore) GetName() string {
|
|
return "postgres"
|
|
}
|
|
|
|
func (store *PostgresStore) Initialize(configuration util.Configuration, prefix string) (err error) {
|
|
// Absent key keeps a pooled default; an explicit 0 disables the idle pool.
|
|
configuration.SetDefault(prefix+"connection_max_idle", 2)
|
|
// Default on so minimal configs are not exposed to duplicate-key tx
|
|
// poisoning on Postgres; an explicit false still disables it.
|
|
configuration.SetDefault(prefix+"enableUpsert", true)
|
|
return store.initialize(
|
|
configuration.GetString(prefix+"upsertQuery"),
|
|
configuration.GetBool(prefix+"enableUpsert"),
|
|
configuration.GetString(prefix+"username"),
|
|
configuration.GetString(prefix+"password"),
|
|
configuration.GetString(prefix+"hostname"),
|
|
configuration.GetInt(prefix+"port"),
|
|
configuration.GetString(prefix+"database"),
|
|
configuration.GetString(prefix+"schema"),
|
|
configuration.GetString(prefix+"sslmode"),
|
|
configuration.GetString(prefix+"sslcert"),
|
|
configuration.GetString(prefix+"sslkey"),
|
|
configuration.GetString(prefix+"sslrootcert"),
|
|
configuration.GetString(prefix+"sslcrl"),
|
|
configuration.GetBool(prefix+"pgbouncer_compatible"),
|
|
configuration.GetInt(prefix+"connection_max_idle"),
|
|
configuration.GetInt(prefix+"connection_max_open"),
|
|
configuration.GetInt(prefix+"connection_max_lifetime_seconds"),
|
|
)
|
|
}
|
|
|
|
func (store *PostgresStore) initialize(upsertQuery string, enableUpsert bool, user, password, hostname string, port int, database, schema, sslmode, sslcert, sslkey, sslrootcert, sslcrl string, pgbouncerCompatible bool, maxIdle, maxOpen, maxLifetimeSeconds int) (err error) {
|
|
|
|
store.SupportBucketTable = false
|
|
if !enableUpsert {
|
|
upsertQuery = ""
|
|
} else if upsertQuery == "" {
|
|
upsertQuery = DefaultUpsertQuery
|
|
}
|
|
gen := &SqlGenPostgres{
|
|
CreateTableSqlTemplate: "",
|
|
DropTableSqlTemplate: `drop table "%s"`,
|
|
UpsertQueryTemplate: upsertQuery,
|
|
}
|
|
store.SqlGenerator = gen
|
|
|
|
// pgx-optimized connection string with better timeouts and connection handling
|
|
sqlUrl := "connect_timeout=30"
|
|
|
|
if hostname != "" {
|
|
sqlUrl += " host=" + hostname
|
|
}
|
|
if port != 0 {
|
|
sqlUrl += " port=" + strconv.Itoa(port)
|
|
}
|
|
|
|
// SSL configuration - pgx provides better SSL support than lib/pq
|
|
if sslmode != "" {
|
|
sqlUrl += " sslmode=" + sslmode
|
|
}
|
|
if sslcert != "" {
|
|
sqlUrl += " sslcert=" + sslcert
|
|
}
|
|
if sslkey != "" {
|
|
sqlUrl += " sslkey=" + sslkey
|
|
}
|
|
if sslrootcert != "" {
|
|
sqlUrl += " sslrootcert=" + sslrootcert
|
|
}
|
|
if sslcrl != "" {
|
|
sqlUrl += " sslcrl=" + sslcrl
|
|
}
|
|
if user != "" {
|
|
sqlUrl += " user=" + user
|
|
}
|
|
adaptedSqlUrl := sqlUrl
|
|
if password != "" {
|
|
sqlUrl += " password=" + password
|
|
adaptedSqlUrl += " password=ADAPTED"
|
|
}
|
|
if database != "" {
|
|
sqlUrl += " dbname=" + database
|
|
adaptedSqlUrl += " dbname=" + database
|
|
}
|
|
if schema != "" && !pgbouncerCompatible {
|
|
sqlUrl += " search_path=" + schema
|
|
adaptedSqlUrl += " search_path=" + schema
|
|
}
|
|
db, openErr := OpenPGXDB(sqlUrl, adaptedSqlUrl, pgbouncerCompatible, maxIdle, maxOpen, maxLifetimeSeconds)
|
|
if openErr != nil {
|
|
return openErr
|
|
}
|
|
store.DB = db
|
|
|
|
ConfigureListOrdering(store.DB, gen)
|
|
|
|
return nil
|
|
}
|