Documentation
¶
Index ¶
- func DefaultHealthCheck(conn *grpc.ClientConn) bool
- func PartitionProxyInterceptor(rm *RingManager, forwarder *RequestForwarder) grpc.UnaryServerInterceptor
- func PartitionProxyStreamInterceptor(rm *RingManager, forwarder *RequestForwarder, aggregator *StreamAggregator) grpc.StreamServerInterceptor
- type ConsistentHash
- func (c *ConsistentHash) AddNode(nodeID string)
- func (c *ConsistentHash) ClearCache()
- func (c *ConsistentHash) GetMetrics() ConsistentHashMetrics
- func (c *ConsistentHash) GetNode(key string) string
- func (c *ConsistentHash) GetNodeUncached(key string) string
- func (c *ConsistentHash) GetPreferenceList(key string, n int) []string
- func (c *ConsistentHash) NodeCount() int
- func (c *ConsistentHash) RemoveNode(nodeID string)
- func (c *ConsistentHash) TotalHashCount() int
- func (c *ConsistentHash) UpdateVNodeCount(nodeID string, count int)
- func (c *ConsistentHash) VirtualNodeCount() int
- type ConsistentHashMetrics
- type ForwarderConfig
- type HealthCheckFunc
- type NodeResolver
- type RequestForwarder
- func (f *RequestForwarder) Close() error
- func (f *RequestForwarder) Forward(ctx context.Context, targetNodeID string, req any, method string) (any, error)
- func (f *RequestForwarder) ForwardStream(ctx context.Context, targetNodeID string, serverStream grpc.ServerStream, ...) error
- func (f *RequestForwarder) GetConn(ctx context.Context, target string) (*grpc.ClientConn, error)
- type Result
- type RingManager
- func (rm *RingManager) GetMembers() []string
- func (rm *RingManager) GetMetaAddr(nodeID string) string
- func (rm *RingManager) GetNode(key string) string
- func (rm *RingManager) GetNodeAddr(nodeID string) string
- func (rm *RingManager) GetPreferenceList(key string, n int) []string
- func (rm *RingManager) IsLocalKey(key string) bool
- func (rm *RingManager) NotifyJoin(member *mesh.Member)
- func (rm *RingManager) NotifyLeave(member *mesh.Member)
- func (rm *RingManager) NotifyUpdate(member *mesh.Member)
- func (rm *RingManager) RouteGeo(dataset string, lat, lon float64, radiusKm float64) []string
- func (rm *RingManager) RouteTemporal(dataset string, startTime, endTime int64) []string
- func (rm *RingManager) UpdateNodeLoad(nodeID string, load float64)
- type ScatterFn
- type ScatterGather
- type StreamAggregator
- type TimeBounds
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHealthCheck ¶
func DefaultHealthCheck(conn *grpc.ClientConn) bool
DefaultHealthCheck uses gRPC connectivity state
func PartitionProxyInterceptor ¶
func PartitionProxyInterceptor(rm *RingManager, forwarder *RequestForwarder) grpc.UnaryServerInterceptor
PartitionProxyInterceptor creates a unary server interceptor for request routing
func PartitionProxyStreamInterceptor ¶
func PartitionProxyStreamInterceptor(rm *RingManager, forwarder *RequestForwarder, aggregator *StreamAggregator) grpc.StreamServerInterceptor
PartitionProxyStreamInterceptor creates a stream server interceptor for request routing
Types ¶
type ConsistentHash ¶
type ConsistentHash struct {
// contains filtered or unexported fields
}
ConsistentHash implements a consistent hashing ring with hot key caching
func NewConsistentHash ¶
func NewConsistentHash(vnodes int) *ConsistentHash
NewConsistentHash creates a new ring with specified vnodes and hot key caching
func NewConsistentHashWithCache ¶
func NewConsistentHashWithCache(vnodes, cacheCapacity int, cacheTTL time.Duration) *ConsistentHash
NewConsistentHashWithCache creates a new ring with custom cache configuration
func (*ConsistentHash) AddNode ¶
func (c *ConsistentHash) AddNode(nodeID string)
AddNode adds a new node to the ring
func (*ConsistentHash) ClearCache ¶
func (c *ConsistentHash) ClearCache()
ClearCache purges the hot key cache
func (*ConsistentHash) GetMetrics ¶
func (c *ConsistentHash) GetMetrics() ConsistentHashMetrics
GetMetrics returns current cache metrics
func (*ConsistentHash) GetNode ¶
func (c *ConsistentHash) GetNode(key string) string
GetNode returns the node responsible for the given key Uses hot key caching for improved performance on repeated lookups
func (*ConsistentHash) GetNodeUncached ¶
func (c *ConsistentHash) GetNodeUncached(key string) string
GetNodeUncached returns the node without using cache (for testing or cache-invalidated paths)
func (*ConsistentHash) GetPreferenceList ¶
func (c *ConsistentHash) GetPreferenceList(key string, n int) []string
GetPreferenceList returns the top N distinct nodes for a key (Replication Strategy)
func (*ConsistentHash) NodeCount ¶
func (c *ConsistentHash) NodeCount() int
NodeCount returns the number of nodes in the ring
func (*ConsistentHash) RemoveNode ¶
func (c *ConsistentHash) RemoveNode(nodeID string)
RemoveNode removes a node from the ring
func (*ConsistentHash) TotalHashCount ¶
func (c *ConsistentHash) TotalHashCount() int
TotalHashCount returns total number of hash points
func (*ConsistentHash) UpdateVNodeCount ¶
func (c *ConsistentHash) UpdateVNodeCount(nodeID string, count int)
UpdateVNodeCount updates the number of virtual nodes for a specific nodeID. This is used for load-based rebalancing (dynamic weighting).
func (*ConsistentHash) VirtualNodeCount ¶
func (c *ConsistentHash) VirtualNodeCount() int
VirtualNodeCount returns the number of virtual nodes
type ConsistentHashMetrics ¶
ConsistentHashMetrics holds performance metrics for the ring
type ForwarderConfig ¶
type ForwarderConfig struct {
DialTimeout time.Duration
Logger zerolog.Logger
HealthCheckInterval time.Duration
HealthCheckFunc HealthCheckFunc
MaxConnAge time.Duration
}
ForwarderConfig holds configuration for the forwarder
func DefaultForwarderConfig ¶
func DefaultForwarderConfig() ForwarderConfig
DefaultForwarderConfig returns default config
type HealthCheckFunc ¶
type HealthCheckFunc func(conn *grpc.ClientConn) bool
HealthCheckFunc is a function that checks if a connection is healthy
type NodeResolver ¶
NodeResolver resolves node IDs to addresses
type RequestForwarder ¶
type RequestForwarder struct {
// contains filtered or unexported fields
}
RequestForwarder handles forwarding gRPC requests to remote nodes
func NewRequestForwarder ¶
func NewRequestForwarder(cfg *ForwarderConfig, resolver NodeResolver) *RequestForwarder
NewRequestForwarder creates a new forwarder
func (*RequestForwarder) Close ¶
func (f *RequestForwarder) Close() error
Close closes all connections and stops the health check goroutine
func (*RequestForwarder) Forward ¶
func (f *RequestForwarder) Forward(ctx context.Context, targetNodeID string, req any, method string) (any, error)
Forward forwards a unary request to the target node transparently. It uses byteCodec to handle any request/response type as raw bytes.
func (*RequestForwarder) ForwardStream ¶
func (f *RequestForwarder) ForwardStream(ctx context.Context, targetNodeID string, serverStream grpc.ServerStream, method string, initialRequest any) error
ForwardStream handles transparent proxying for streaming gRPC calls. initialRequest is optional and should be provided if the request has already been consumed by the handler (e.g., in Server-Streaming RPCs like DoGet).
func (*RequestForwarder) GetConn ¶
func (f *RequestForwarder) GetConn(ctx context.Context, target string) (*grpc.ClientConn, error)
GetConn returns or creates a connection to the target
type RingManager ¶
type RingManager struct {
// contains filtered or unexported fields
}
RingManager coordinates the consistent hash ring with the cluster membership state
func NewRingManager ¶
func NewRingManager(localNodeID string, logger zerolog.Logger) *RingManager
NewRingManager creates a new RingManager
func (*RingManager) GetMembers ¶
func (rm *RingManager) GetMembers() []string
GetMembers returns a list of all known node IDs in the ring
func (*RingManager) GetMetaAddr ¶
func (rm *RingManager) GetMetaAddr(nodeID string) string
GetMetaAddr returns the metadata/search service network address for a given node ID
func (*RingManager) GetNode ¶
func (rm *RingManager) GetNode(key string) string
GetNode returns the owner of a key
func (*RingManager) GetNodeAddr ¶
func (rm *RingManager) GetNodeAddr(nodeID string) string
GetNodeAddr returns the data service network address for a given node ID
func (*RingManager) GetPreferenceList ¶
func (rm *RingManager) GetPreferenceList(key string, n int) []string
GetPreferenceList returns the replication nodes for a key
func (*RingManager) IsLocalKey ¶
func (rm *RingManager) IsLocalKey(key string) bool
IsLocalKey returns true if the key belongs to the local node
func (*RingManager) NotifyJoin ¶
func (rm *RingManager) NotifyJoin(member *mesh.Member)
NotifyJoin is invoked when a node joins the cluster
func (*RingManager) NotifyLeave ¶
func (rm *RingManager) NotifyLeave(member *mesh.Member)
NotifyLeave is invoked when a node leaves the cluster
func (*RingManager) NotifyUpdate ¶
func (rm *RingManager) NotifyUpdate(member *mesh.Member)
NotifyUpdate is invoked when a node is updated
func (*RingManager) RouteGeo ¶
func (rm *RingManager) RouteGeo(dataset string, lat, lon float64, radiusKm float64) []string
func (*RingManager) RouteTemporal ¶
func (rm *RingManager) RouteTemporal(dataset string, startTime, endTime int64) []string
func (*RingManager) UpdateNodeLoad ¶
func (rm *RingManager) UpdateNodeLoad(nodeID string, load float64)
UpdateNodeLoad updates the reported load for a node and triggers rebalancing if necessary
type ScatterFn ¶
ScatterFn is the function to execute on each node It takes a context (with timeout) and the target node ID
type ScatterGather ¶
type ScatterGather struct {
// contains filtered or unexported fields
}
ScatterGather coordinates distributed request execution
func NewScatterGather ¶
func NewScatterGather(rm *RingManager, forwarder *RequestForwarder, logger zerolog.Logger) *ScatterGather
NewScatterGather creates a new ScatterGather coordinator
type StreamAggregator ¶
type StreamAggregator struct {
// contains filtered or unexported fields
}
StreamAggregator consolidates results from multiple Flight streams
func NewStreamAggregator ¶
func NewStreamAggregator(mem memory.Allocator, logger zerolog.Logger) *StreamAggregator
NewStreamAggregator creates a new aggregator
func (*StreamAggregator) Aggregate ¶
func (sa *StreamAggregator) Aggregate(ctx context.Context, sg *ScatterGather, k int, scatterFn ScatterFn) ([]arrow.RecordBatch, error)
Aggregate performs a scatter-gather-merge for Flight streams. It executes the scatter function, collects all resulting streams, reads them into memory, merges (sorts) the results, and returns the top K rows as a new RecordBatch.
Fault Tolerance: Failed shards are logged and ignored. Partial results are returned.
type TimeBounds ¶
TimeBounds represents a min and max timestamp.