Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable configuring local address and range of ports for client sockets to be bound to #1027

Open
wprzytula opened this issue Jul 4, 2024 · 0 comments
Labels
cpp-rust-driver-p1 Functionality required by cpp-rust-driver enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@wprzytula
Copy link
Collaborator

Motivation

Cpp driver exposes the following functions. Their docstrings contain motivation for both.

/**
 * Sets the local address to bind when connecting to the cluster,
 * if desired.
 *
 * @public @memberof CassCluster
 *
 * @param[in] cluster
 * @param[in] name IP address to bind, or empty string for no binding.
 * Only numeric addresses are supported; no resolution is done.
 * @return CASS_OK if successful, otherwise an error occurred.
 */
CASS_EXPORT CassError
cass_cluster_set_local_address(CassCluster* cluster,
                               const char* name);
/**
 * Sets the range of outgoing port numbers (ephemeral ports) to be
 * used when establishing the shard-aware connections. This is
 * applicable when the routing of connection to shard is based on
 * the client-side port number.
 * 
 * When application connects to multiple CassCluster-s it is advised
 * to assign mutually non-overlapping port intervals to each. It is assumed
 * that the supplied range is allowed by the OS (e.g. it fits inside
 * /proc/sys/net/ipv4/ip_local_port_range on *nix systems)
 *
 * @public @memberof CassCluster
 *
 * @param[in] cluster
 * @param[in] lo The lower bound (inclusive)
 * @param[in] hi The upper bound (exclusive)
 * @return CASS_OK if successful, otherwise the range is invalid.
 */
CassError cass_cluster_set_local_port_range(CassCluster* cluster,
                                            int lo,
                                            int hi);

Implementing them both make sense for Rust driver itself, as well as to support them in cpp-rust-driver.

Solution

Add the following methods to SessionBuilder (and corresponding config to SessionConfig, and respect it codewide):

fn driver_bind_address(self, addr: SocketAddr) -> Self;

fn driver_bind_port_range(self, port_range: Range<u16>) -> Self;
@wprzytula wprzytula added this to the 1.0.0 milestone Jul 4, 2024
@wprzytula wprzytula added enhancement New feature or request good first issue Good for newcomers cpp-rust-driver-p1 Functionality required by cpp-rust-driver labels Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp-rust-driver-p1 Functionality required by cpp-rust-driver enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant