Files
zeekayandHanzo Dev c3e231795c Hanzo Kafka: one name for the Kafka-wire adaptor
This is the Kafka interface to Hanzo PubSub, not a product of its own. "Stream"
described the transport rather than the contract, and left two names for one
thing -- the repo was already redirecting hanzoai/kafka -> hanzoai/stream, so
imports and docs disagreed with the canonical URL.

The layering it belongs to:

  hanzoai/tasks       workloads and async workflows
        |
  hanzoai/pubsub      the ONE event bus (JetStream-durable NATS)
        |
  hanzoai/kafka       Kafka-wire adaptor   (AMQP is the sibling seam)
        |
  hanzoai/datastore   the ONE warehouse

Module path is now github.com/hanzoai/kafka; binary, image labels and docs say
Hanzo Kafka.

The word "stream" survives wherever it names the PROTOCOL rather than the
product -- JetStream stream names, ParseStreamName, the subject patterns in
pubsub/streams.go. Renaming those would have broken the wire contract to make a
brand consistent.

Unit tests pass. test/cluster and test/e2e still fail identically to before this
change: they shell out to an Apache Kafka distribution at ~/kafka_2.13-3.9.0/
that is not installed here, so they are unrelated to the rename.

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-30 06:02:35 -07:00

60 lines
1.8 KiB
Go

package main
import (
"os"
"os/signal"
"syscall"
log "github.com/hanzoai/kafka/logging"
"github.com/hanzoai/kafka/protocol"
"github.com/hanzoai/kafka/types"
"github.com/spf13/cobra"
)
var config = types.Configuration{
PubSubUrl: "nats://localhost:4222",
BrokerHost: "localhost",
BrokerPort: 9092,
AdminPort: 9093,
NodeID: 1,
StreamReplicas: 1,
StorageType: "file",
}
func main() {
var rootCmd = &cobra.Command{
Use: "hanzo-kafka",
Short: "Hanzo Kafka — Kafka wire protocol gateway for Hanzo PubSub",
Run: func(cmd *cobra.Command, args []string) {
broker := protocol.NewBroker(&config)
log.SetLogLevel(log.INFO)
// Handle termination signals (e.g., Ctrl+C)
signalChannel := make(chan os.Signal, 1)
signal.Notify(signalChannel, syscall.SIGINT, syscall.SIGTERM)
go func() {
sig := <-signalChannel
log.Info("Received signal: %s. Shutting down...", sig)
broker.Shutdown()
os.Exit(0)
}()
// Start the broker
broker.Startup()
},
}
rootCmd.Flags().StringVar(&config.PubSubUrl, "pubsub-url", "nats://localhost:4222", "Hanzo PubSub server URL")
rootCmd.Flags().StringVar(&config.PubSubCredFile, "pubsub-creds", "", "Hanzo PubSub credentials file")
rootCmd.Flags().IntVar(&config.BrokerPort, "port", 9092, "Kafka listener port")
rootCmd.Flags().IntVar(&config.AdminPort, "admin-port", 9093, "Admin HTTP port (0 to disable)")
rootCmd.Flags().StringVar(&config.BrokerHost, "host", "localhost", "Advertised hostname")
rootCmd.Flags().IntVar(&config.NodeID, "node-id", 1, "Broker node ID")
rootCmd.Flags().IntVar(&config.StreamReplicas, "replicas", 1, "Hanzo Kafka replica count")
rootCmd.Flags().StringVar(&config.StorageType, "storage", "file", "Hanzo Kafka storage type: file or memory")
if err := rootCmd.Execute(); err != nil {
log.Panic("Failed to execute root command %v", err)
}
}