Documentation
¶
Overview ¶
Package pub implements the queue client.
Index ¶
- func DataNode(name, addr string) schema.Metadata
- func KeepNode(client queue.Client, node schema.Metadata, interval time.Duration, ...) (stop func())
- func New(metadata metadata.Repo, roles ...databasev1.Role) queue.Client
- func NewWithoutMetadata(omr observability.MetricsRegistry, opts ...Option) queue.Client
- func ResolveResourceOptsForUpdate(l *logger.Logger, groupSchema *commonv1.Group, nodeLabels map[string]string) *commonv1.ResourceOpts
- func ResolveStageResourceOpts(ro *commonv1.ResourceOpts, nodeLabels map[string]string) (resolved *commonv1.ResourceOpts, matchedStage *commonv1.LifecycleStage, ...)
- type ChunkedSyncClientConfig
- type LabelSelector
- type MatchFunc
- type Option
- type StageResolution
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataNode ¶ added in v0.12.0
DataNode is the metadata that registers the data node at addr under name on a client made by NewWithoutMetadata. The ROLE_DATA role is required: the client's role gate (allowedRoles=[ROLE_DATA]) silently drops a node whose roles do not intersect, which would leave the client with nowhere to send.
func KeepNode ¶ added in v0.12.0
func KeepNode(client queue.Client, node schema.Metadata, interval time.Duration, l *logger.Logger) (stop func())
KeepNode registers node on client and keeps it connected until the returned function is called. A client made by NewWithoutMetadata runs a synchronous health check at registration and does not retry an evicted node (healthCheckInterval is 0), so the keeper registers the node again whenever it is not healthy -- covering both an initial dial that failed (the node is not ready yet) and a later failover eviction.
Stop is idempotent and returns once the keeper has exited.
func New ¶
New returns a new queue client targeting the given node roles. If no roles are passed, it defaults to databasev1.Role_ROLE_DATA.
func NewWithoutMetadata ¶ added in v0.8.0
func NewWithoutMetadata(omr observability.MetricsRegistry, opts ...Option) queue.Client
NewWithoutMetadata returns a new queue client without metadata, defaulting to data nodes. sender_* fields are left empty for this lifecycle-tool publisher.
If omr is non-nil, a parallel banyandb_lifecycle_migration_* metric family is registered on it. The regular banyandb_queue_pub_* family stays disabled because metadata is nil (PreRun gates it on metadata != nil). Pass nil to leave the migration metrics disabled (e.g. tests, or non-migration clients).
func ResolveResourceOptsForUpdate ¶ added in v0.11.0
func ResolveResourceOptsForUpdate(l *logger.Logger, groupSchema *commonv1.Group, nodeLabels map[string]string) *commonv1.ResourceOpts
ResolveResourceOptsForUpdate resolves the ResourceOpts a data node applies when a group is updated: the matched stage's interval/ttl/shardNum, or the group default when no stage applies. On a resolution error it keeps the group default rather than failing the update, and returns nil when the group carries no ResourceOpts. This is the shared body of every data supplier's ResolveResourceOpts.
func ResolveStageResourceOpts ¶ added in v0.11.0
func ResolveStageResourceOpts(ro *commonv1.ResourceOpts, nodeLabels map[string]string) ( resolved *commonv1.ResourceOpts, matchedStage *commonv1.LifecycleStage, matchedIdx int, err error, )
ResolveStageResourceOpts resolves the effective ResourceOpts for a data node whose lifecycle stage is selected by nodeLabels. It returns a deep clone of ro with SegmentInterval, Ttl (cumulative through the matched stage) and ShardNum overridden by the matched stage. matchedStage/matchedIdx identify the matched stage and are nil/-1 when no stage applies (the group has no stages, the node has no labels, or no stage selector matched the node's labels). The returned opts is always a fresh clone, so callers never mutate the shared group schema.
This is the single source of truth for the per-stage interval/ttl/shard resolution: both the initial OpenDB and any later UpdateOptions must go through it, otherwise a group update silently overwrites a stage node's interval/ttl with the group default.
Types ¶
type ChunkedSyncClientConfig ¶ added in v0.9.0
type ChunkedSyncClientConfig struct {
ChunkSize uint32 // Size of each chunk in bytes
EnableRetryOnOOO bool // Enable retry on out-of-order errors
MaxOOORetries int // Maximum retries for out-of-order chunks
OOORetryDelay time.Duration // Delay between retries
}
ChunkedSyncClientConfig configures chunked sync client behavior.
type LabelSelector ¶ added in v0.8.0
type LabelSelector struct {
// contains filtered or unexported fields
}
LabelSelector is a selector for labels.
func ParseLabelSelector ¶ added in v0.8.0
func ParseLabelSelector(selector string) (*LabelSelector, error)
ParseLabelSelector parses a label selector string.
type Option ¶ added in v0.12.0
type Option func(*pub)
Option configures a client made by NewWithoutMetadata, which registers no flag set to configure it through.
func WithClientTLS ¶ added in v0.12.0
WithClientTLS makes the client dial with TLS. caCertPath verifies the server; empty, the system roots do. insecureSkipVerify skips verifying the server's certificate.
func WithLogger ¶ added in v0.12.0
WithLogger names the logger the client and its connections log under.
type StageResolution ¶ added in v0.11.0
type StageResolution struct {
// ResourceOpts holds the effective SegmentInterval/Ttl/ShardNum -- the matched stage's
// values (cumulative ttl) or the group default. It is always a fresh clone.
ResourceOpts *commonv1.ResourceOpts
SegmentIdleTimeout time.Duration
// Matched reports whether the node matched a lifecycle stage (a warm/cold tier); the
// hot/initial tier and unlabeled nodes are not matched.
Matched bool
DisableRetention bool
DisableRotation bool
}
StageResolution is the fully-resolved storage configuration for a data node's tsdb, derived from the group ResourceOpts and the node's matched lifecycle stage. It carries everything OpenDB needs so the caller does no further stage logic.
Only ResourceOpts is re-applied on a group UpdateOptions; the rotation/retention fields are wired once at open time, so adding/removing/retiming a stage needs a node restart.
func ResolveStage ¶ added in v0.11.0
func ResolveStage(l *logger.Logger, groupName string, ro *commonv1.ResourceOpts, nodeLabels map[string]string) (StageResolution, error)
ResolveStage resolves the complete tsdb configuration for this node from the group opts and the node's lifecycle stage. A labeled node whose group has stages and that matches none of them serves the group's default (hot) stage with the group-default options; that is the normal case of every hot node, so it is logged at info level, naming the labels, for an operator to spot a warm or cold node whose labels miss its stage's selector. This is the single entry point OpenDB uses.