Skip to main content

Client Config and Dial

GitHub source:

The SDK entry point is client.Dial(ctx, cfg).

Core Types​

  • client.Config
  • client.Client

What Dial Does​

Dial(...) is not just a raw TCP connect. It:

  1. applies config defaults
  2. validates that bootstrap endpoints exist
  3. creates the transport client
  4. performs metadata bootstrap
  5. starts background metadata refresh behavior for long-lived clients

That means a successful Dial(...) is already a stronger signal than “socket open”.

Key Config Fields​

Connection and Bootstrap​

  • Endpoints
    • required bootstrap addresses
  • DialTimeout
  • RequestTimeout
  • BootstrapBackoffInitial
  • BootstrapBackoffMax
  • BootstrapMaxAttempts

Metadata and Routing​

  • MetadataRefreshTimeout
  • MetadataRefreshInterval
  • EndpointCooldown
  • PreferredListenerName

Client Identity and Hooks​

  • ClientSoftwareName
  • ClientSoftwareVersion
  • Authenticator
  • Dialer
  • SnapshotStorage
  • SnapshotFetcher

Common Call Pattern​

ctx := context.Background()

cli, err := client.Dial(ctx, client.Config{
Endpoints: []string{"127.0.0.1:9123"},
})
if err != nil {
log.Fatal(err)
}
defer cli.Close()

What You Get Back​

Dial(...) returns a *client.Client. The main next-step methods are:

  • Admin()
  • Table(path)
  • RefreshMetadata(...)
  • Close()

When to Customize Config​

Use defaults first unless you have a clear reason to tune:

  • backoff and timeout behavior
  • listener selection in multi-network environments
  • custom auth hooks
  • snapshot storage or custom snapshot fetching

Important Caveats​

  • Endpoints is required.
  • Metadata-advertised coordinator and tablet addresses must also be reachable after bootstrap.
  • SnapshotStorage is only needed for the current snapshot-fetch path, not for ordinary admin or table operations.

Positioning​

This page is a curated reference page, not generated godoc. It should stay focused on how callers actually use the SDK, not on reprinting every implementation detail.