Documentation
¶
Overview ¶
Package multiserver provides support for managing multiple S3 connections.
Index ¶
- type ConnectionConfig
- type Manager
- func (m *Manager) AddConnection(cfg ConnectionConfig, createNow bool) error
- func (m *Manager) ClientProvider() func(name string) (tools.S3Client, error)
- func (m *Manager) Close() error
- func (m *Manager) DefaultConnectionName() string
- func (m *Manager) GetClient(ctx context.Context, name string) (tools.S3Client, error)
- func (m *Manager) GetDefaultClient(ctx context.Context) (tools.S3Client, error)
- func (m *Manager) HasConnection(name string) bool
- func (m *Manager) IsClientInitialized(name string) bool
- func (m *Manager) ListConnections() []string
- func (m *Manager) RemoveConnection(name string) error
- type MultiConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionConfig ¶
type ConnectionConfig struct {
// Name is the unique identifier for this connection.
Name string `json:"name" yaml:"name"`
// Region is the AWS region.
Region string `json:"region,omitempty" yaml:"region,omitempty"`
// Endpoint is an optional custom endpoint URL.
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
// AccessKeyID is the AWS access key ID.
AccessKeyID string `json:"access_key_id,omitempty" yaml:"access_key_id,omitempty"`
// SecretAccessKey is the AWS secret access key.
SecretAccessKey string `json:"secret_access_key,omitempty" yaml:"secret_access_key,omitempty"`
// SessionToken is an optional session token.
SessionToken string `json:"session_token,omitempty" yaml:"session_token,omitempty"`
// Profile is an optional AWS profile name.
Profile string `json:"profile,omitempty" yaml:"profile,omitempty"`
// UsePathStyle enables path-style addressing.
UsePathStyle bool `json:"use_path_style,omitempty" yaml:"use_path_style,omitempty"`
// DisableSSL disables SSL/TLS.
DisableSSL bool `json:"disable_ssl,omitempty" yaml:"disable_ssl,omitempty"`
}
ConnectionConfig represents configuration for a single S3 connection.
func (*ConnectionConfig) ToClientConfig ¶
func (c *ConnectionConfig) ToClientConfig() *client.Config
ToClientConfig converts a ConnectionConfig to a client.Config.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages multiple S3 connections with lazy initialization.
func NewManager ¶
func NewManager(config *MultiConfig) *Manager
NewManager creates a new connection manager with the given configuration.
func NewManagerWithFactory ¶
func NewManagerWithFactory(config *MultiConfig, factory func(ctx context.Context, cfg *client.Config) (tools.S3Client, error)) *Manager
NewManagerWithFactory creates a new connection manager with a custom client factory. Useful for testing.
func (*Manager) AddConnection ¶
func (m *Manager) AddConnection(cfg ConnectionConfig, createNow bool) error
AddConnection adds a new connection configuration and optionally creates the client.
func (*Manager) ClientProvider ¶
ClientProvider returns a function that can be used as a client provider for the toolkit.
func (*Manager) DefaultConnectionName ¶
DefaultConnectionName returns the name of the default connection.
func (*Manager) GetClient ¶
GetClient returns a client for the given connection name. If the client doesn't exist, it is created lazily.
func (*Manager) GetDefaultClient ¶
GetDefaultClient returns the client for the default connection.
func (*Manager) HasConnection ¶
HasConnection returns true if a connection with the given name exists.
func (*Manager) IsClientInitialized ¶
IsClientInitialized returns true if a client for the given connection has been created.
func (*Manager) ListConnections ¶
ListConnections returns a list of all available connection names.
func (*Manager) RemoveConnection ¶
RemoveConnection removes a connection and closes its client if it exists.
type MultiConfig ¶
type MultiConfig struct {
// DefaultConnection is the name of the default connection.
DefaultConnection string `json:"default_connection,omitempty" yaml:"default_connection,omitempty"`
// Connections is a list of connection configurations.
Connections []ConnectionConfig `json:"connections" yaml:"connections"`
}
MultiConfig holds configuration for multiple S3 connections.
func FromEnvJSON ¶
func FromEnvJSON() (*MultiConfig, error)
FromEnvJSON loads multi-connection configuration from the S3_ADDITIONAL_CONNECTIONS environment variable, which should contain a JSON object mapping connection names to connection configurations.
func FromJSONFile ¶
func FromJSONFile(path string) (*MultiConfig, error)
FromJSONFile loads multi-connection configuration from a JSON file.
func FromYAMLFile ¶
func FromYAMLFile(path string) (*MultiConfig, error)
FromYAMLFile loads multi-connection configuration from a YAML file.
func (*MultiConfig) ConnectionNames ¶
func (c *MultiConfig) ConnectionNames() []string
ConnectionNames returns a list of all connection names.
func (*MultiConfig) GetConnection ¶
func (c *MultiConfig) GetConnection(name string) *ConnectionConfig
GetConnection returns the configuration for a specific connection by name.