Skip to main content
pub struct WorkerList  /* private fields */ 

A list of worker URLs to use for multi-head operations.

The addresses belong to the connection, not to this list. A Kinetica instance discovers each cluster’s rank addresses, applies the connection’s hostname regex to them, and keeps the result per cluster; this struct is a view onto that, held by a bulk inserter or record retriever.

It does not resolve or filter addresses of its own. A filter has no coherent meaning here, because it cannot survive a failover: one tuned for a cluster’s addressing may match nothing on the next, and multi-head objects fail over with the connection. Set the regex on the connection instead — see KineticaOptions::set_hostname_regex — where it is applied to every cluster as that cluster is discovered.

The one choice that is meaningful per object is declining multi-head altogether; see WorkerList::empty. That names an intent rather than an address, and an intent transfers across clusters where a list of addresses does not.

Note entry i of this list is rank i + 1; the head rank is not a member, and a rank removed from the cluster keeps its slot as None. The worker indices in the shard routing table are rank numbers, so compacting the list would silently misroute every rank above the hole.

Example

Implementations

Source

pub fn empty() -> Self

Creates an empty WorkerList, which declines multi-head operations for the bulk inserter or record retriever it is given to.

That object will route through the head node for its lifetime. The choice is authoritative: it is not undone when the worker list is rebuilt after a failover or a shard rebalance.

This is the way to decline multi-head for a single object while keeping the connection’s fail-over. Disabling auto-discovery is not equivalent — it also stops the client discovering the other clusters in an HA ring, so it costs fail-over as well.

Nothing inside this crate may use this constructor: it is a caller’s way of expressing an intent, and an internal use would silently pin its own list to head-node-only. Internal code wanting a list with no addresses builds one through WorkerList::with_urls instead.

Source

pub fn from_cluster(db: &Arc<Kinetica>) -> Self

Creates a WorkerList from the worker rank addresses the given connection has already discovered for the cluster it is currently on.

This reads the connection’s addresses; it does not query the server or re-resolve them. They were filtered through the connection’s hostname regex when that cluster was discovered, so they already reflect it.

If the connection has no worker addresses for the current cluster — multi-head is off at the server, or the cluster advertises none this client can use — the list is empty and the object using it operates through the head node.

  • db - The Kinetica instance whose addresses to use

Whether multi-head operations can be used with this list.

Whether the list names any worker rank.

Source

pub fn len(&self) -> usize

Returns the number of workers in the list.

Source

pub fn is_empty(&self) -> bool

Returns true if the worker list is empty.

Source

pub fn get(&self, index: usize) -> Option<&Url>

Gets the URL at the specified index.

  • index - The index of the worker URL to get (0-based, corresponds to rank-1)

The URL at the specified index, or None if the rank was removed or the index is out of bounds.

Source

pub fn urls(&self) -> &Vec<Option<Url>>

Returns a reference to the underlying vector of URLs.

None entries represent removed worker ranks.

Source

pub fn iter(&self) -> impl Iterator<Item = &Option<Url>>

Returns an iterator over the URLs in the worker list.

This iterator yields references to Option<Url>, where None represents removed worker ranks.

Source

pub fn push(&mut self, url: Option<Url>)

Adds a URL to the worker list.

  • url - The URL to add, or None to add a placeholder for a removed rank
Source

pub fn add(&mut self, url: Url)

Adds a URL to the worker list (convenience method that wraps in Some).

  • url - The URL to add

Converts the worker list to a vector of URL strings.

This method filters out None entries (removed ranks) and returns only the valid URL strings.

The result is compacted, so its indices are no longer rank numbers. Routing a sharded record through these indices sends every rank above a removed one to the wrong host. Use Self::urls and index by slot, or let the bulk inserter build its rank mapping from the slot positions. This is only safe where any live worker will do — round-robin distribution, health checks, and the like.

A vector of URL strings for all valid (non-removed) workers.

Consumes the worker list and returns a vector of URL strings.

This method filters out None entries (removed ranks) and returns only the valid URL strings.

The result is compacted; see Self::to_url_strings for why that makes it unusable for routing sharded records.

A vector of URL strings for all valid (non-removed) workers.

Trait Implementations

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source

fn fmt(&self, f: &mut Formatter<’_>) -> Result

Formats the value using the given formatter. Read more
Source

impl Default for WorkerList

The same as WorkerList::empty, which declines multi-head operations. Internal code must not use it, as empty says.

Source

fn default() -> Self

Returns the “default value” for a type. Read more
Source

fn eq(&self, other: &Self) -> bool

Two lists are equal when they name the same ranks, holes included.

The head-node-only intent is deliberately excluded: this compares addresses, and it is what the rebuild paths use to decide whether a cluster’s addresses have actually changed.

1.0.0 (const: unstable) · Source

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.