Skip to content

Commit f27a82f

Browse files
committed
fix: expose IncludeDedicatedClusterManagers in opensearch.Config
The documentation showed an example using IncludeDedicatedClusterManagers in opensearch.Config.Transport, but this didn't work because: - Transport expects http.RoundTripper, not opensearchtransport.Config - IncludeDedicatedClusterManagers was only available in the low-level transport config, not exposed through the high-level API Changes: - Add IncludeDedicatedClusterManagers field to opensearch.Config - Pass field through to transport config in NewClient() - Fix documentation example to use the new direct configuration - Update terminology from "cluster master" to "cluster manager" Fixes broken documentation example and provides proper API access to dedicated cluster manager node inclusion settings. Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
1 parent d8de55f commit f27a82f

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

guides/node_discovery_and_roles.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,12 @@ client, err := opensearch.NewClient(opensearch.Config{
9494
DiscoverNodesOnStart: true,
9595
DiscoverNodesInterval: 5 * time.Minute,
9696
97-
// Configure transport with cluster master exclusion
98-
Transport: &opensearchtransport.Config{
99-
// Default behavior (can be omitted): excludes dedicated cluster managers
100-
// IncludeDedicatedClusterManagers: false,
97+
// Configure cluster manager exclusion (default: false)
98+
// Default behavior: excludes dedicated cluster managers
99+
// IncludeDedicatedClusterManagers: false,
101100
102-
// To include dedicated cluster managers, set to true:
103-
// IncludeDedicatedClusterManagers: true,
104-
},
101+
// To include dedicated cluster managers, set to true:
102+
// IncludeDedicatedClusterManagers: true,
105103
})
106104
```
107105

opensearch.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ type Config struct {
9191
DiscoverNodesOnStart bool // Discover nodes synchronously when initializing the client (blocks until complete). Default: false.
9292
DiscoverNodesInterval time.Duration // Discover nodes periodically in background. Default: disabled.
9393

94+
// IncludeDedicatedClusterManagers includes dedicated cluster manager nodes in request routing.
95+
// When false (default), dedicated cluster manager nodes are excluded from client requests,
96+
// following best practices and matching the Java client's NodeSelector.SKIP_DEDICATED_CLUSTER_MASTERS behavior.
97+
// When true, all nodes including dedicated cluster managers can receive client requests.
98+
// Default: false (excludes dedicated cluster managers for better performance)
99+
IncludeDedicatedClusterManagers bool
100+
94101
EnableMetrics bool // Enable the metrics collection.
95102
EnableDebugLogger bool // Enable the debug logging.
96103

@@ -181,6 +188,8 @@ func NewClient(cfg Config) (*Client, error) {
181188
DiscoverNodesOnStart: cfg.DiscoverNodesOnStart,
182189
DiscoverNodesInterval: cfg.DiscoverNodesInterval,
183190

191+
IncludeDedicatedClusterManagers: cfg.IncludeDedicatedClusterManagers,
192+
184193
Transport: cfg.Transport,
185194
Logger: cfg.Logger,
186195
Selector: cfg.Selector,

0 commit comments

Comments
 (0)