Documentation
¶
Overview ¶
Package multiserver provides support for managing connections to multiple DataHub servers.
Index ¶
- Constants
- type Config
- type ConnectionConfig
- type ConnectionInfo
- type Manager
- func (m *Manager) Client(name string) (*client.Client, error)
- func (m *Manager) Close() error
- func (m *Manager) Config() Config
- func (m *Manager) ConnectionCount() int
- func (m *Manager) ConnectionInfos() []ConnectionInfo
- func (m *Manager) Connections() []string
- func (m *Manager) DefaultClient() (*client.Client, error)
- func (m *Manager) HasConnection(name string) bool
Constants ¶
const DefaultConnectionName = "datahub"
DefaultConnectionName is the fallback name for the primary connection.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Default is the display name of the primary connection.
// This can be customized via DATAHUB_CONNECTION_NAME env var.
// Defaults to "datahub" if not specified.
Default string
// Primary is the primary connection configuration (from DATAHUB_* env vars).
Primary client.Config
// Connections maps connection names to their configurations.
// The primary connection is always available under the Default name.
Connections map[string]ConnectionConfig
}
Config holds configuration for multiple DataHub connections.
func FromEnv ¶
FromEnv builds a multi-server configuration from environment variables.
Primary server configuration comes from standard DATAHUB_* variables. Additional servers come from DATAHUB_ADDITIONAL_SERVERS as JSON:
{"staging": {"url": "https://staging.datahub.example.com", "token": "xxx"}}
The primary connection name can be customized via DATAHUB_CONNECTION_NAME (defaults to "datahub").
Additional servers inherit token, timeout, retry_max, etc. from the primary if not explicitly specified.
func (Config) ClientConfig ¶
ClientConfig returns a client.Config for the named connection. Returns the primary config if name is empty or matches the default connection name. Returns an error if the connection name is not found.
func (Config) ConnectionCount ¶
ConnectionCount returns the total number of connections (including default).
func (Config) ConnectionInfos ¶
func (c Config) ConnectionInfos() []ConnectionInfo
ConnectionInfos returns information about all connections for display.
func (Config) ConnectionNames ¶
ConnectionNames returns the names of all available connections. Always includes the primary connection name as the first entry.
type ConnectionConfig ¶
type ConnectionConfig struct {
// URL is the DataHub GMS URL (required for additional servers).
URL string `json:"url"`
// Token is the personal access token. Inherits from primary if empty.
Token string `json:"token,omitempty"`
// Timeout is the request timeout in seconds. Inherits from primary if zero.
Timeout int `json:"timeout,omitempty"`
// RetryMax is the maximum retry attempts. Inherits from primary if zero.
RetryMax int `json:"retry_max,omitempty"`
// DefaultLimit is the default search result limit. Inherits from primary if zero.
DefaultLimit int `json:"default_limit,omitempty"`
// MaxLimit is the maximum allowed limit. Inherits from primary if zero.
MaxLimit int `json:"max_limit,omitempty"`
// MaxLineageDepth is the maximum lineage traversal depth. Inherits from primary if zero.
MaxLineageDepth int `json:"max_lineage_depth,omitempty"`
// WriteEnabled enables write operations for this connection.
// nil = inherit from toolkit config, true/false = explicit override.
WriteEnabled *bool `json:"write_enabled,omitempty"`
}
ConnectionConfig defines configuration for a single DataHub connection. Fields that are empty/zero inherit from the primary connection.
type ConnectionInfo ¶
type ConnectionInfo struct {
Name string `json:"name"`
URL string `json:"url"`
IsDefault bool `json:"is_default"`
}
ConnectionInfo holds display information about a connection.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages connections to multiple DataHub servers. It lazily creates client connections on first use.
func NewManager ¶
NewManager creates a new connection manager with the given configuration. Clients are created lazily on first access, not at construction time.
func NewManagerFromEnv ¶
NewManagerFromEnv creates a Manager using configuration from environment variables.
func SingleClientManager ¶
SingleClientManager creates a Manager with only a default connection. This is useful for backwards compatibility with code that uses a single client.
func (*Manager) Client ¶
Client returns the DataHub client for the named connection. If name is empty, returns the primary connection's client. Clients are created lazily and cached for reuse.
func (*Manager) ConnectionCount ¶
ConnectionCount returns the number of configured connections.
func (*Manager) ConnectionInfos ¶
func (m *Manager) ConnectionInfos() []ConnectionInfo
ConnectionInfos returns information about all configured connections.
func (*Manager) Connections ¶
Connections returns the names of all configured connections.
func (*Manager) DefaultClient ¶
DefaultClient returns the default (primary) connection's client.
func (*Manager) HasConnection ¶
HasConnection returns true if the named connection exists.