Documentation
¶
Overview ¶
Package queue implements the data transmission queue.
Index ¶
- Variables
- func ClearChunkedSyncFailureInjector()
- func FillPartContext(c *ChunkedSyncPartContext, info *clusterv1.PartInfo)
- func FinishPart(c *ChunkedSyncPartContext) error
- func RegisterChunkedSyncFailureInjector(injector ChunkedSyncFailureInjector)
- type BatchPublisher
- type ChunkedSyncClient
- type ChunkedSyncFailureInjector
- type ChunkedSyncHandler
- type ChunkedSyncPartContext
- type Client
- type FailedPart
- type FileData
- type FileInfo
- type PartHandler
- type PartSealer
- type PendingParts
- type Queue
- type Server
- type StreamingPartData
- type SyncMetadata
- type SyncResult
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("not implemented")
ErrNotImplemented is returned by Client implementations that have no peers to dial — notably the standalone local pipeline. Callers (e.g. the cluster barrier fan-out) treat this sentinel as "no peer to probe; skip" rather than as a hard failure, so the standalone path degrades to in-process self-probing without a special-cased branch in the caller.
var ErrServerBusy = errors.New("receiver under memory pressure")
ErrServerBusy signals the receiver is under memory pressure and the sender should back off and retry the whole part.
Functions ¶
func ClearChunkedSyncFailureInjector ¶ added in v0.9.0
func ClearChunkedSyncFailureInjector()
ClearChunkedSyncFailureInjector removes the registered failure injector.
func FillPartContext ¶ added in v0.11.3
func FillPartContext(c *ChunkedSyncPartContext, info *clusterv1.PartInfo)
FillPartContext copies the description of a part from the sync protocol into c.
func FinishPart ¶ added in v0.11.3
func FinishPart(c *ChunkedSyncPartContext) error
FinishPart finishes the part c holds, if any, and drops its handler.
func RegisterChunkedSyncFailureInjector ¶ added in v0.9.0
func RegisterChunkedSyncFailureInjector(injector ChunkedSyncFailureInjector)
RegisterChunkedSyncFailureInjector registers a failure injector for testing.
Types ¶
type BatchPublisher ¶ added in v0.5.0
BatchPublisher is the interface for publishing data in batch.
type ChunkedSyncClient ¶ added in v0.9.0
type ChunkedSyncClient interface {
// SyncStreamingParts sends streaming parts using chunked transfer.
SyncStreamingParts(ctx context.Context, parts []StreamingPartData) (*SyncResult, error)
// Close releases resources associated with the client.
Close() error
}
ChunkedSyncClient provides methods for chunked data synchronization with streaming support.
type ChunkedSyncFailureInjector ¶ added in v0.9.0
type ChunkedSyncFailureInjector interface {
// BeforeSync returns whether the current SyncStreamingParts invocation should
// short-circuit. The returned slice provides the failed parts that should be
// reported back to the caller when a failure is injected.
BeforeSync(parts []StreamingPartData) (bool, []FailedPart, error)
}
ChunkedSyncFailureInjector allows tests to deterministically inject failures into chunked sync operations. It is only intended for test code.
func GetChunkedSyncFailureInjector ¶ added in v0.9.0
func GetChunkedSyncFailureInjector() ChunkedSyncFailureInjector
GetChunkedSyncFailureInjector returns the currently registered failure injector.
type ChunkedSyncHandler ¶ added in v0.9.0
type ChunkedSyncHandler interface {
// HandleFileChunk processes incoming file chunks as they arrive.
// This method is called for each chunk of file data to enable streaming processing.
HandleFileChunk(ctx *ChunkedSyncPartContext, chunk []byte) error
// CreatePartHandler creates a new part handler for the given context.
CreatePartHandler(ctx *ChunkedSyncPartContext) (PartHandler, error)
}
ChunkedSyncHandler handles incoming chunked sync requests on the server side.
type ChunkedSyncPartContext ¶ added in v0.9.0
type ChunkedSyncPartContext struct {
Handler PartHandler
// Context carries the gRPC stream context for receive-side cancellation
// (memory wait upper bound / disconnect).
Context context.Context
Group string
FileName string
PartType string
ID uint64
CompressedSizeBytes uint64
UncompressedSizeBytes uint64
TotalCount uint64
BlocksCount uint64
MinTimestamp int64
MaxTimestamp int64
MinKey int64
MaxKey int64
ShardID uint32
}
ChunkedSyncPartContext represents the context for a chunked sync operation.
func SwitchPart ¶ added in v0.11.3
func SwitchPart(ctx context.Context, cur *ChunkedSyncPartContext, pending *PendingParts, md *clusterv1.SyncMetadata, info *clusterv1.PartInfo, handler ChunkedSyncHandler, ) (*ChunkedSyncPartContext, error)
SwitchPart returns the context of the part info describes, the one chunked sync receiver step shared by the cluster receiver and the in-process relay. A frame continuing the open part cur returns cur, telling its handler about a new part type when the type changes; a frame starting another part finishes cur into pending (see PendingParts.Finish) and creates the new part's handler. On an error the returned context is the one to close: cur when it could not be finished, the new one when its handler could not be created.
func (*ChunkedSyncPartContext) Close ¶ added in v0.9.0
func (c *ChunkedSyncPartContext) Close() error
Close releases resources associated with the context.
func (*ChunkedSyncPartContext) RetrieveContext ¶ added in v0.11.0
func (c *ChunkedSyncPartContext) RetrieveContext() context.Context
RetrieveContext returns the part's stream context, or context.Background() if none was set. Used by receive handlers to bound memory-pressure waits.
type Client ¶ added in v0.5.0
type Client interface {
run.Unit
bus.Publisher
bus.Broadcaster
route.TableProvider
// NewBatchPublisher creates a batch publisher whose timeout starts when Close seals the batch.
NewBatchPublisher(timeout time.Duration) BatchPublisher
NewChunkedSyncClient(node string, chunkSize uint32) (ChunkedSyncClient, error)
// SetSelfNode stamps the publisher's own node identity onto the wire
// (SenderNode / SenderRole / SenderTier on every SendRequest) and onto
// the banyandb_lifecycle_migration_* metric labels. Pass "" for any
// dimension the caller doesn't know (e.g. the lifecycle has no Role
// enum entry; the tier is untracked when the co-located data node's
// tier isn't known at boot time).
SetSelfNode(name, role, tier string)
// NewNodeSchemaStatusClient returns a client for the cluster.v1
// NodeSchemaStatusService against the named node, sharing the underlying
// *grpc.ClientConn from this queue client's existing connection pool.
// The standalone local pipeline returns ErrNotImplemented so callers can
// treat it as "no peer to probe" without a type-switch.
NewNodeSchemaStatusClient(node string) (clusterv1.NodeSchemaStatusServiceClient, error)
Register(bus.Topic, schema.EventHandler)
OnAddOrUpdate(md schema.Metadata)
GracefulStop()
HealthyNodes() []string
}
Client is the interface for publishing data to the queue.
type FailedPart ¶ added in v0.9.0
FailedPart contains information about a part that failed to sync.
type FileInfo ¶ added in v0.9.0
FileInfo represents information about an individual file within a part.
type PartHandler ¶ added in v0.9.0
type PartHandler interface {
NewPartType(ctx *ChunkedSyncPartContext) error
FinishSync() error
Close() error
}
PartHandler handles individual parts during sync operations.
type PartSealer ¶ added in v0.11.3
type PartSealer interface {
// SealSync writes what remains of the part, as FinishSync does, without introducing it.
// FinishSync of a sealed part only introduces it; Close of a sealed part removes it.
SealSync() error
}
PartSealer is a PartHandler whose part can be completed on disk without being introduced. A chunked sync session seals every part it finishes before the sender's completion arrives, so a session that fails midway leaves none of its parts in the receiver: the sender resends every part of a failed session, and parts introduced before the failure would be stored twice.
type PendingParts ¶ added in v0.11.3
type PendingParts struct {
// contains filtered or unexported fields
}
PendingParts holds the parts of a chunked sync session that are sealed but not introduced yet. A nil PendingParts finishes every part at once.
func (*PendingParts) Commit ¶ added in v0.11.3
func (p *PendingParts) Commit(c *ChunkedSyncPartContext) error
Commit completes the session: it finishes the open part c into p, then introduces every part p holds in the order they were finished.
When c cannot be sealed, Commit returns the error at once and introduces nothing: c and every part p holds are left for the caller to Discard. When a held part cannot be introduced, the parts before it stay introduced, that part and every part after it are discarded, and the error is returned.
func (*PendingParts) Discard ¶ added in v0.11.3
func (p *PendingParts) Discard(c *ChunkedSyncPartContext) error
Discard abandons the session: it closes the open part c, if any, and removes every part p holds, so none of them is introduced. It is the counterpart of Commit, and every path that ends a session without its completion calls it once with the session's open part. It returns the errors the parts reported while closing.
func (*PendingParts) Finish ¶ added in v0.11.3
func (p *PendingParts) Finish(c *ChunkedSyncPartContext) error
Finish finishes the part c holds, if any, and drops it from c. A part whose handler is a PartSealer is sealed and kept until Commit or Discard; any other part is finished at once.
type Server ¶ added in v0.5.0
type Server interface {
run.Unit
bus.Subscriber
RegisterChunkedSyncHandler(topic bus.Topic, handler ChunkedSyncHandler)
GetPort() *uint32
SetRouteProviders(providers map[string]route.TableProvider)
// SetMetadataRepo enables fodc.v1.GroupLifecycleService — liaison-only
// by design; data-node processes must not call it.
SetMetadataRepo(repo metadata.Repo)
// SetNodeSchemaStatusRepo enables cluster.v1.NodeSchemaStatusService —
// per-node by design (reports the local schema cache); liaison and
// data-node processes both call it.
SetNodeSchemaStatusRepo(svc metadata.Service)
}
Server is the interface for receiving data from the queue.
type StreamingPartData ¶ added in v0.9.0
type StreamingPartData struct {
Group string
Topic string
PartType string
Files []FileInfo
ID uint64
CompressedSizeBytes uint64
UncompressedSizeBytes uint64
TotalCount uint64
BlocksCount uint64
MinTimestamp int64
MaxTimestamp int64
MinKey int64
MaxKey int64
ShardID uint32
}
StreamingPartData represents streaming part data for syncing.
type SyncMetadata ¶ added in v0.9.0
type SyncMetadata = clusterv1.SyncMetadata
SyncMetadata is an alias for clusterv1.SyncMetadata.
type SyncResult ¶ added in v0.9.0
type SyncResult struct {
SessionID string
FailedParts []FailedPart
TotalBytes uint64
DurationMs int64
ChunksCount uint32
PartsCount uint32
Success bool
}
SyncResult represents the result of a sync operation.