Skip to content

[Docs] Include a code example for rack-awareness #108

Description

@GeoffMontee

In master of cpp-driver and in 0.3.0 and later of cpp-rust-driver, the driver supports rack-awareness.

Perhaps we could add some examples to the documentation.

It looks like there are two primary methods to use that we could document.

  • Set directly on a CassCluster object:
/* Setup and connect to cluster */
CassFuture* connect_future = NULL;
CassCluster* cluster = cass_cluster_new();
CassSession* session = cass_session_new();

cass_cluster_set_contact_points(cluster, "192.168.1.1,192.168.1.2,192.168.1.3");
cass_cluster_set_load_balance_rack_aware(cluster,
                                       "AWS_US_EAST_1",
                                       "us-east-1a");
connect_future = cass_session_connect(session, cluster);

if (cass_future_error_code(connect_future) == CASS_OK) {
   //do work
} else {
   /* Handle connection error */
   const char* message;
   size_t message_length;
   cass_future_error_message(connect_future, &message, &message_length);
   fprintf(stderr, "Unable to connect: '%.*s'\n", (int)message_length, message);
}

cass_future_free(connect_future);
cass_cluster_free(cluster);
cass_session_free(session);
  • Set on a CassExecProfile object:
//FIXME: fill in example

We might also want to include a disclaimer about AWS specifically, where AZs do not have consistent names between different AWS accounts. Maybe the documentation can provide more detailed guidance about this or refer to the AWS documentation that mentions how to obtain the internal AZ IDs. Here's the corresponding AWS Documentation page: Availability Zone IDs for your AWS resources

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions