broker

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	// contains filtered or unexported fields
}

Broker represents a StreamBus broker instance

func New

func New(config *Config) (*Broker, error)

New creates a new broker instance

func (*Broker) IsAlive

func (b *Broker) IsAlive() bool

IsAlive returns true if the broker is alive (not stopped)

func (*Broker) IsLeader

func (b *Broker) IsLeader() bool

IsLeader returns true if this broker is the Raft leader

func (*Broker) IsReady

func (b *Broker) IsReady() bool

IsReady returns true if the broker is ready to accept requests

func (*Broker) SecurityManager

func (b *Broker) SecurityManager() *security.Manager

Stop stops the broker gracefully SecurityManager returns the security manager

func (*Broker) Start

func (b *Broker) Start() error

Start starts the broker

func (*Broker) Status

func (b *Broker) Status() BrokerStatus

Status returns the current broker status

func (*Broker) Stop

func (b *Broker) Stop() error

Stop stops the broker

func (*Broker) TenancyManager

func (b *Broker) TenancyManager() *tenancy.Manager

TenancyManager returns the tenancy manager

func (*Broker) WaitForShutdown

func (b *Broker) WaitForShutdown()

WaitForShutdown blocks until the broker is stopped

type BrokerInfo

type BrokerInfo struct {
	ID        int32            `json:"id"`
	Host      string           `json:"host"`
	Port      int              `json:"port"`
	Status    string           `json:"status"`
	Leader    bool             `json:"leader"`
	Version   string           `json:"version"`
	Uptime    string           `json:"uptime"`
	Resources *BrokerResources `json:"resources,omitempty"`
}

BrokerInfo represents broker metadata for API responses

type BrokerResources

type BrokerResources struct {
	CPUPercent    float64 `json:"cpu_percent"`
	MemoryPercent float64 `json:"memory_percent"`
	DiskPercent   float64 `json:"disk_percent"`
	DiskUsedGB    int64   `json:"disk_used_gb"`
	DiskTotalGB   int64   `json:"disk_total_gb"`
}

BrokerResources represents broker resource usage

type BrokerStatus

type BrokerStatus int

BrokerStatus represents the broker's current status

const (
	StatusStopped BrokerStatus = iota
	StatusStarting
	StatusRunning
	StatusStopping
)

type ClusterInfo

type ClusterInfo struct {
	ClusterID       string `json:"cluster_id"`
	ControllerID    int32  `json:"controller_id"`
	Version         string `json:"version"`
	TotalBrokers    int    `json:"total_brokers"`
	ActiveBrokers   int    `json:"active_brokers"`
	TotalTopics     int    `json:"total_topics"`
	TotalPartitions int    `json:"total_partitions"`
	Uptime          string `json:"uptime"`
}

ClusterInfo represents cluster metadata

type Config

type Config struct {
	// Broker identity
	BrokerID int32
	Host     string
	Port     int

	// Network ports
	GRPCPort int
	HTTPPort int

	// Storage configuration
	DataDir string

	// Raft configuration
	RaftDataDir string
	RaftPeers   []consensus.Peer

	// Server configuration
	Server *server.Config

	// Security configuration
	Security *security.SecurityConfig

	// Multi-tenancy configuration
	EnableMultiTenancy bool

	// Logging
	LogLevel string
}

Config holds broker configuration

type ConsumerGroupInfo

type ConsumerGroupInfo struct {
	GroupID     string       `json:"group_id"`
	State       string       `json:"state"`
	Protocol    string       `json:"protocol"`
	Members     []MemberInfo `json:"members"`
	Coordinator int32        `json:"coordinator"`
	TotalLag    int64        `json:"total_lag"`
}

ConsumerGroupInfo represents consumer group metadata

type LagInfo

type LagInfo struct {
	Topic     string `json:"topic"`
	Partition int32  `json:"partition"`
	MemberID  string `json:"member_id"`
	Offset    int64  `json:"offset"`
	EndOffset int64  `json:"end_offset"`
	Lag       int64  `json:"lag"`
}

LagInfo represents lag information for a partition

type MemberInfo

type MemberInfo struct {
	MemberID   string  `json:"member_id"`
	ClientID   string  `json:"client_id"`
	ClientHost string  `json:"client_host"`
	Partitions []int32 `json:"partitions"`
	JoinedAt   int64   `json:"joined_at"`
}

MemberInfo represents consumer group member metadata

type MessageInfo

type MessageInfo struct {
	Offset    int64             `json:"offset"`
	Key       string            `json:"key,omitempty"`
	Value     string            `json:"value"`
	Headers   map[string]string `json:"headers,omitempty"`
	Timestamp int64             `json:"timestamp"`
}

MessageInfo represents message metadata for browsing

type PartitionInfo

type PartitionInfo struct {
	ID              int32   `json:"id"`
	Leader          int32   `json:"leader"`
	Replicas        []int32 `json:"replicas"`
	ISR             []int32 `json:"isr"`
	BeginningOffset int64   `json:"beginning_offset"`
	EndOffset       int64   `json:"end_offset"`
	MessageCount    int64   `json:"message_count"`
}

PartitionInfo represents partition metadata

type SchemaRegistrationRequest added in v1.1.0

type SchemaRegistrationRequest struct {
	Format     string `json:"format"`
	Definition string `json:"definition"`
}

SchemaRegistrationRequest is the JSON body for registering a schema.

type SchemaResponse added in v1.1.0

type SchemaResponse struct {
	ID         int32  `json:"id"`
	Subject    string `json:"subject,omitempty"`
	Version    int32  `json:"version,omitempty"`
	Format     string `json:"format,omitempty"`
	Definition string `json:"definition,omitempty"`
}

SchemaResponse is the JSON response for schema operations.

type TopicResponse

type TopicResponse struct {
	Name              string          `json:"name"`
	NumPartitions     int             `json:"num_partitions"`
	ReplicationFactor int             `json:"replication_factor"`
	Partitions        []PartitionInfo `json:"partitions,omitempty"`
}

TopicResponse represents topic metadata for API responses

Jump to

Keyboard shortcuts

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