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.
128 lines
4.6 KiB
Go
128 lines
4.6 KiB
Go
package broker
|
|
|
|
// Broker Error Codes
|
|
// These codes are used internally by the broker and can be mapped to Kafka protocol error codes
|
|
const (
|
|
// Success
|
|
BrokerErrorNone int32 = 0
|
|
|
|
// General broker errors
|
|
BrokerErrorUnknownServerError int32 = 1
|
|
BrokerErrorTopicNotFound int32 = 2
|
|
BrokerErrorPartitionNotFound int32 = 3
|
|
BrokerErrorNotLeaderOrFollower int32 = 6 // Maps to Kafka ErrorCodeNotLeaderOrFollower
|
|
BrokerErrorRequestTimedOut int32 = 7
|
|
BrokerErrorBrokerNotAvailable int32 = 8
|
|
BrokerErrorMessageTooLarge int32 = 10
|
|
BrokerErrorNetworkException int32 = 13
|
|
BrokerErrorOffsetLoadInProgress int32 = 14
|
|
BrokerErrorInvalidRecord int32 = 42
|
|
BrokerErrorTopicAlreadyExists int32 = 36
|
|
BrokerErrorInvalidPartitions int32 = 37
|
|
BrokerErrorInvalidConfig int32 = 40
|
|
|
|
// Publisher/connection errors
|
|
BrokerErrorPublisherNotFound int32 = 100
|
|
BrokerErrorConnectionFailed int32 = 101
|
|
BrokerErrorFollowerConnectionFailed int32 = 102
|
|
)
|
|
|
|
// BrokerErrorInfo contains metadata about a broker error
|
|
type BrokerErrorInfo struct {
|
|
Code int32
|
|
Name string
|
|
Description string
|
|
KafkaCode int16 // Corresponding Kafka protocol error code
|
|
}
|
|
|
|
// BrokerErrors maps broker error codes to their metadata and Kafka equivalents
|
|
var BrokerErrors = map[int32]BrokerErrorInfo{
|
|
BrokerErrorNone: {
|
|
Code: BrokerErrorNone, Name: "NONE",
|
|
Description: "No error", KafkaCode: 0,
|
|
},
|
|
BrokerErrorUnknownServerError: {
|
|
Code: BrokerErrorUnknownServerError, Name: "UNKNOWN_SERVER_ERROR",
|
|
Description: "Unknown server error", KafkaCode: 1,
|
|
},
|
|
BrokerErrorTopicNotFound: {
|
|
Code: BrokerErrorTopicNotFound, Name: "TOPIC_NOT_FOUND",
|
|
Description: "Topic not found", KafkaCode: 3, // UNKNOWN_TOPIC_OR_PARTITION
|
|
},
|
|
BrokerErrorPartitionNotFound: {
|
|
Code: BrokerErrorPartitionNotFound, Name: "PARTITION_NOT_FOUND",
|
|
Description: "Partition not found", KafkaCode: 3, // UNKNOWN_TOPIC_OR_PARTITION
|
|
},
|
|
BrokerErrorNotLeaderOrFollower: {
|
|
Code: BrokerErrorNotLeaderOrFollower, Name: "NOT_LEADER_OR_FOLLOWER",
|
|
Description: "Not leader or follower for this partition", KafkaCode: 6,
|
|
},
|
|
BrokerErrorRequestTimedOut: {
|
|
Code: BrokerErrorRequestTimedOut, Name: "REQUEST_TIMED_OUT",
|
|
Description: "Request timed out", KafkaCode: 7,
|
|
},
|
|
BrokerErrorBrokerNotAvailable: {
|
|
Code: BrokerErrorBrokerNotAvailable, Name: "BROKER_NOT_AVAILABLE",
|
|
Description: "Broker not available", KafkaCode: 8,
|
|
},
|
|
BrokerErrorMessageTooLarge: {
|
|
Code: BrokerErrorMessageTooLarge, Name: "MESSAGE_TOO_LARGE",
|
|
Description: "Message size exceeds limit", KafkaCode: 10,
|
|
},
|
|
BrokerErrorNetworkException: {
|
|
Code: BrokerErrorNetworkException, Name: "NETWORK_EXCEPTION",
|
|
Description: "Network error", KafkaCode: 13,
|
|
},
|
|
BrokerErrorOffsetLoadInProgress: {
|
|
Code: BrokerErrorOffsetLoadInProgress, Name: "OFFSET_LOAD_IN_PROGRESS",
|
|
Description: "Offset loading in progress", KafkaCode: 14,
|
|
},
|
|
BrokerErrorInvalidRecord: {
|
|
Code: BrokerErrorInvalidRecord, Name: "INVALID_RECORD",
|
|
Description: "Invalid record", KafkaCode: 42,
|
|
},
|
|
BrokerErrorTopicAlreadyExists: {
|
|
Code: BrokerErrorTopicAlreadyExists, Name: "TOPIC_ALREADY_EXISTS",
|
|
Description: "Topic already exists", KafkaCode: 36,
|
|
},
|
|
BrokerErrorInvalidPartitions: {
|
|
Code: BrokerErrorInvalidPartitions, Name: "INVALID_PARTITIONS",
|
|
Description: "Invalid partition count", KafkaCode: 37,
|
|
},
|
|
BrokerErrorInvalidConfig: {
|
|
Code: BrokerErrorInvalidConfig, Name: "INVALID_CONFIG",
|
|
Description: "Invalid configuration", KafkaCode: 40,
|
|
},
|
|
BrokerErrorPublisherNotFound: {
|
|
Code: BrokerErrorPublisherNotFound, Name: "PUBLISHER_NOT_FOUND",
|
|
Description: "Publisher not found", KafkaCode: 1, // UNKNOWN_SERVER_ERROR
|
|
},
|
|
BrokerErrorConnectionFailed: {
|
|
Code: BrokerErrorConnectionFailed, Name: "CONNECTION_FAILED",
|
|
Description: "Connection failed", KafkaCode: 13, // NETWORK_EXCEPTION
|
|
},
|
|
BrokerErrorFollowerConnectionFailed: {
|
|
Code: BrokerErrorFollowerConnectionFailed, Name: "FOLLOWER_CONNECTION_FAILED",
|
|
Description: "Failed to connect to follower brokers", KafkaCode: 13, // NETWORK_EXCEPTION
|
|
},
|
|
}
|
|
|
|
// GetBrokerErrorInfo returns error information for the given broker error code
|
|
func GetBrokerErrorInfo(code int32) BrokerErrorInfo {
|
|
if info, exists := BrokerErrors[code]; exists {
|
|
return info
|
|
}
|
|
return BrokerErrorInfo{
|
|
Code: code, Name: "UNKNOWN", Description: "Unknown broker error code", KafkaCode: 1,
|
|
}
|
|
}
|
|
|
|
// CreateBrokerError creates a structured broker error with both error code and message
|
|
func CreateBrokerError(code int32, message string) (int32, string) {
|
|
info := GetBrokerErrorInfo(code)
|
|
if message == "" {
|
|
message = info.Description
|
|
}
|
|
return code, message
|
|
}
|