factory

package
v4.13.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package factory provides factory functions for creating TeamVault connectors and HTTP clients.

This package simplifies the creation of TeamVault connectors by providing high-level factory functions that handle configuration parsing and proper initialization of connector chains including caching and disk fallback capabilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateConnector

func CreateConnector(
	httpClient *http.Client,
	apiURL teamvault.Url,
	apiUser teamvault.User,
	apiPassword teamvault.Password,
	staging teamvault.Staging,
	cacheEnabled bool,
	currentDateTime libtime.CurrentDateTime,
) teamvault.Connector

CreateConnector creates a new TeamVault Connector based on staging and cache settings. Returns a dummy connector for staging environments, or a disk fallback connector when cache is enabled.

func CreateConnectorWithConfig

func CreateConnectorWithConfig(
	ctx context.Context,
	httpClient *http.Client,
	configPath teamvault.TeamvaultConfigPath,
	apiURL teamvault.Url,
	apiUser teamvault.User,
	apiPassword teamvault.Password,
	staging teamvault.Staging,
	cacheEnabled bool,
	currentDateTime libtime.CurrentDateTime,
) (teamvault.Connector, error)

CreateConnectorWithConfig creates a new TeamVault Connector using configuration from a file or parameters. If the config file exists, it takes precedence over the individual parameters. Delegates to CreateConnectorWithConfigAndKeychain using the real OS Keychain.

func CreateConnectorWithConfigAndKeychain added in v4.9.0

func CreateConnectorWithConfigAndKeychain(
	ctx context.Context,
	httpClient *http.Client,
	configPath teamvault.TeamvaultConfigPath,
	apiURL teamvault.Url,
	apiUser teamvault.User,
	apiPassword teamvault.Password,
	staging teamvault.Staging,
	cacheEnabled bool,
	currentDateTime libtime.CurrentDateTime,
	keychain teamvault.Keychain,
) (teamvault.Connector, error)

CreateConnectorWithConfigAndKeychain is the dependency-injected variant of CreateConnectorWithConfig. Production callers use CreateConnectorWithConfig, which delegates to this with teamvault.NewKeychain(). Tests inject a fake Keychain to drive resolution-chain scenarios.

func CreateConnectorWithConfigAndTimeout added in v4.11.0

func CreateConnectorWithConfigAndTimeout(
	ctx context.Context,
	httpClient *http.Client,
	configPath teamvault.TeamvaultConfigPath,
	apiURL teamvault.Url,
	apiUser teamvault.User,
	apiPassword teamvault.Password,
	staging teamvault.Staging,
	cacheEnabled bool,
	currentDateTime libtime.CurrentDateTime,
	keychain teamvault.Keychain,
	cliTimeout libtime.Duration,
) (teamvault.Connector, error)

CreateConnectorWithConfigAndTimeout is like CreateConnectorWithConfigAndKeychain but also accepts a CLI-supplied timeout. Resolution order: cliTimeout > config.Timeout > 5s default. Negative cliTimeout returns a wrapped error.

func CreateHttpClient

func CreateHttpClient(ctx context.Context) (*http.Client, error)

CreateHttpClient creates a new HTTP client configured for TeamVault API communication. The client has a default timeout of 5 seconds.

func CreateRemoteConnector

func CreateRemoteConnector(
	httpClient *http.Client,
	apiURL teamvault.Url,
	apiUser teamvault.User,
	apiPassword teamvault.Password,
	currentDateTime libtime.CurrentDateTime,
) teamvault.Connector

CreateRemoteConnector creates a new Connector that communicates directly with a remote TeamVault API.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL