broker

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 23 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithConnInfo

func ContextWithConnInfo(ctx context.Context, info *ConnContext) context.Context

ContextWithConnInfo attaches connection info to a context.

Types

type ConnContext

type ConnContext struct {
	Principal  string
	RemoteAddr string
	ProxyAddr  string
}

ConnContext carries connection-scoped identity data for auth decisions.

func ConnInfoFromContext

func ConnInfoFromContext(ctx context.Context) *ConnContext

ConnInfoFromContext returns connection info if present.

type ConnContextFunc

type ConnContextFunc func(conn net.Conn) (net.Conn, *ConnContext, error)

ConnContextFunc can wrap a connection and attach connection-scoped context data.

type CoordinatorConfig deprecated

type CoordinatorConfig struct {
	CleanupInterval time.Duration
}

CoordinatorConfig preserves the published v1.6.3 configuration, including comparability and unkeyed literals.

Deprecated: use CoordinatorOptions with NewGroupCoordinatorWithOptions. Removal requires an announced future breaking release; none is scheduled.

type CoordinatorOptions

type CoordinatorOptions struct {
	CleanupInterval time.Duration
	// Zero uses the seven-day default; a negative value disables retention.
	OffsetsRetention          time.Duration
	RetentionCheckInterval    time.Duration
	RetentionFullScanInterval time.Duration
	AcquireGroup              func(context.Context, string) error
	ReleaseGroup              func(string)
	AcquireRetentionSweep     func(context.Context) error
	// OwnsGroup gates group mutation and cleanup after coordination lease loss.
	// Nil permits standalone coordinators without an external lease manager.
	OwnsGroup func(string) bool
	// GroupDeleted releases external ownership after the coordinator lock is released.
	GroupDeleted func(string)
}

CoordinatorOptions configures retention and optional coordination hooks.

type GroupCoordinator

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

func NewGroupCoordinator deprecated

func NewGroupCoordinator(store metadata.Store, broker protocol.MetadataBroker, cfg *CoordinatorConfig) *GroupCoordinator

NewGroupCoordinator constructs a coordinator using the published configuration.

Deprecated: use NewGroupCoordinatorWithOptions for retention and lease hooks.

func NewGroupCoordinatorWithOptions

func NewGroupCoordinatorWithOptions(store metadata.Store, broker protocol.MetadataBroker, cfg *CoordinatorOptions) *GroupCoordinator

NewGroupCoordinatorWithOptions constructs a coordinator with optional retention and lease hooks.

func (*GroupCoordinator) DeleteGroups

func (*GroupCoordinator) DescribeGroups

func (*GroupCoordinator) FindCoordinatorResponse

func (c *GroupCoordinator) FindCoordinatorResponse(errorCode int16) *kmsg.FindCoordinatorResponse

func (*GroupCoordinator) Heartbeat

func (*GroupCoordinator) JoinGroup

func (*GroupCoordinator) JoinGroupWithClient

func (c *GroupCoordinator) JoinGroupWithClient(ctx context.Context, req *kmsg.JoinGroupRequest, clientID string) (response *kmsg.JoinGroupResponse, resultErr error)

JoinGroupWithClient records display metadata separately from authentication.

func (*GroupCoordinator) LeaveGroup

func (*GroupCoordinator) ListGroups

func (*GroupCoordinator) OffsetCommit

func (*GroupCoordinator) OffsetFetch

func (*GroupCoordinator) Stop

func (c *GroupCoordinator) Stop()

Stop terminates background cleanup routines.

func (*GroupCoordinator) SyncGroup

type Handler

type Handler interface {
	Handle(ctx context.Context, header *protocol.RequestHeader, req kmsg.Request) ([]byte, error)
}

Handler processes parsed Kafka protocol requests and returns the response payload.

type ProxyInfo

type ProxyInfo struct {
	SourceAddr string
	DestAddr   string
	SourceIP   string
	DestIP     string
	SourcePort int
	DestPort   int
	Local      bool
}

ProxyInfo captures parsed proxy protocol metadata.

func ReadProxyProtocol

func ReadProxyProtocol(conn net.Conn) (net.Conn, *ProxyInfo, error)

ReadProxyProtocol consumes a PROXY protocol header (v1 or v2) if present. It returns a wrapped connection that preserves buffered bytes.

type S3HealthConfig

type S3HealthConfig struct {
	Window      time.Duration
	LatencyWarn time.Duration
	LatencyCrit time.Duration
	ErrorWarn   float64
	ErrorCrit   float64
	MaxSamples  int
}

S3HealthConfig defines thresholds for transitioning between states.

type S3HealthMonitor

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

S3HealthMonitor aggregates recent S3 requests to determine a health state.

func NewS3HealthMonitor

func NewS3HealthMonitor(cfg S3HealthConfig) *S3HealthMonitor

NewS3HealthMonitor builds a health monitor with sane defaults.

func (*S3HealthMonitor) RecordOperation

func (m *S3HealthMonitor) RecordOperation(op string, latency time.Duration, err error)

RecordOperation records an arbitrary S3 operation outcome. Conditional write conflicts fence a writer, not S3 availability; their latency still counts.

func (*S3HealthMonitor) RecordUpload

func (m *S3HealthMonitor) RecordUpload(latency time.Duration, err error)

RecordUpload remains for backward compatibility.

func (*S3HealthMonitor) Snapshot

func (m *S3HealthMonitor) Snapshot() S3HealthSnapshot

Snapshot returns the current state and key aggregates.

func (*S3HealthMonitor) State

func (m *S3HealthMonitor) State() S3HealthState

State returns just the current health state.

type S3HealthSnapshot

type S3HealthSnapshot struct {
	State      S3HealthState
	Since      time.Time
	AvgLatency time.Duration
	ErrorRate  float64
}

S3HealthSnapshot captures the monitor's public metrics.

type S3HealthState

type S3HealthState string

S3HealthState models the broker's view of S3 availability.

const (
	S3StateHealthy     S3HealthState = "healthy"
	S3StateDegraded    S3HealthState = "degraded"
	S3StateUnavailable S3HealthState = "unavailable"
)

type Server

type Server struct {
	Addr string
	// WriteTimeout defaults to 30 seconds when nonpositive.
	WriteTimeout    time.Duration
	Handler         Handler
	ConnContextFunc ConnContextFunc
	// contains filtered or unexported fields
}

Server implements minimal Kafka TCP handling for milestone 1.

func (*Server) ListenAddress

func (s *Server) ListenAddress() string

ListenAddress returns the actual listener address if the server has started.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context) error

ListenAndServe starts accepting Kafka protocol connections.

func (*Server) Wait

func (s *Server) Wait()

Wait blocks until all connection goroutines exit.

Jump to

Keyboard shortcuts

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