connector

package
v0.5.0-rc.9 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 48 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// DefaultRuntimePoolMaxEntries bounds SQL pools retained by one process.
	DefaultRuntimePoolMaxEntries = 128
	// DefaultRuntimePoolIdleTimeout retires a pool unused by connector work.
	DefaultRuntimePoolIdleTimeout = 10 * time.Minute
	// DefaultRuntimePoolMaxLifetime bounds reuse of one connector pool revision.
	DefaultRuntimePoolMaxLifetime = time.Hour
	// DefaultRuntimePoolCleanupInterval controls background idle and lifetime eviction.
	DefaultRuntimePoolCleanupInterval = time.Minute
)

Variables

View Source
var (
	// ErrRuntimePoolClosed reports acquisition after manager shutdown.
	ErrRuntimePoolClosed = xerror.ExecutionUnavailable().Detail("connector runtime pool is closed")
	// ErrRuntimePoolExhausted reports that every bounded entry is still active.
	ErrRuntimePoolExhausted = xerror.ExecutionUnavailable().Detail("connector runtime pool is full")
	// ErrRuntimePoolRevisionRetired reports an older revision that is still draining.
	ErrRuntimePoolRevisionRetired = xerror.ExecutionUnavailable().Detail(
		"connector runtime pool revision is retired",
	)
)
View Source
var ErrMetadataUnsupported = xerror.Unsupported(xerror.DataSource).Detail("selected-resource Proof metadata is unsupported for this connector operation")
View Source
var ErrUnsafeConfigIdentity = xerror.New(xerror.KindInvalidInput, "DATA_SOURCE_CONFIG_IDENTITY_UNAVAILABLE", "data source configuration cannot be pinned safely")

Functions

func BindMetadataPlan

func BindMetadataPlan(plan proofevidence.MetadataPlan, config json.RawMessage, credentialKind string) (proofevidence.MetadataPlan, error)

BindMetadataPlan derives protocol/authentication settings from the tenant's actual connection, without credentials or a provider call.

func Execute

func Execute(ctx context.Context, conn Connector, statement json.RawMessage, params map[string]types.TypedParam, scope *resourcescope.Scope, limits types.ExecutionLimits) (*result.ExecutionResult, error)

Execute preserves ordinary execution for historical requests. A scoped request cannot fall back to a connector that does not implement its policy.

func FTPArtifactConnector

func FTPArtifactConnector(conn Connector) (*ftp.Connector, bool)

FTPArtifactConnector obtains the private artifact capability from the configured factory, including when ordinary execution tracing wraps it.

func MetadataPolicies

func MetadataPolicies(limits proofevidence.Limits) []proofevidence.OperationPolicy

MetadataPolicies is the explicit connector portfolio allowlist, independent of connection tests, introspection, pipeline execution and transport choice.

func NormalizeCustomerConfig

func NormalizeCustomerConfig(dsType model.DataSourceType, raw []byte) ([]byte, bool, error)

NormalizeCustomerConfig enforces the public data-source config contract before customer payloads are validated, tested, or persisted.

func PublicConfigDigest

func PublicConfigDigest(kind model.DataSourceType, raw []byte) (string, error)

PublicConfigDigest hashes only the public connector contract. URL credentials and late substitutions cannot become provenance, even through a hash.

func ValidateTransportConfig

func ValidateTransportConfig(config any, allowPlaintext bool) error

ValidateTransportConfig rejects unsafe endpoints before a customer config can be saved or tested.

func WithDataSourceIdentity

func WithDataSourceIdentity(ctx context.Context, organization, dataSource slug.Slug) context.Context

WithDataSourceIdentity carries the authorized resource identity to execution.

func WithOrganizationSlug

func WithOrganizationSlug(ctx context.Context, organizationSlug slug.Slug) context.Context

WithOrganizationSlug binds deployment-owned connector defaults to one tenant.

Types

type BigQueryDefaults

type BigQueryDefaults struct {
	BaseURL           string
	TokenURL          string
	AllowPrivateHosts bool
}

BigQueryDefaults configures operator-controlled endpoint defaults for the BigQuery connector. It keeps private endpoint routing out of the public data source API shape.

type Connector

type Connector interface {
	// Execute runs the query described by queryData with the provided TypedParam values.
	// Each connector is responsible for normalizing parameter values based on DataType.
	// Returns a structured ExecutionResult containing type-specific data and metadata.
	Execute(
		ctx context.Context,
		queryData json.RawMessage,
		params map[string]types.TypedParam,
		limits ...types.ExecutionLimits,
	) (*result.ExecutionResult, error)

	// TestConnection verifies that a connection to the data source can be established
	// with the configured credentials.
	TestConnection(ctx context.Context) error

	// Close closes the connector and releases any held resources (connection pools, etc.).
	Close() error
}

Connector verifies connectivity and manages connector lifecycle.

func NewConnector

func NewConnector(
	ctx context.Context,
	dsType model.DataSourceType,
	configJSON, credentialsJSON []byte,
) (Connector, error)

NewConnector is the production connector factory function. It handles config/credentials unmarshaling and instantiation for all supported data source types.

type DecodedConnectorPayloads

type DecodedConnectorPayloads struct {
	Config                any
	Credentials           any
	PrivateHostsRequested bool
}

DecodedConnectorPayloads carries typed connector config and credentials for callers that need validation without constructing a live connector.

func DecodeConnectorPayloads

func DecodeConnectorPayloads(
	dsType model.DataSourceType,
	configJSON, credentialsJSON []byte,
) (DecodedConnectorPayloads, bool, error)

DecodeConnectorPayloads decodes config and credentials through the production registry without constructing a connector.

type HubSpotDefaults

type HubSpotDefaults struct {
	BaseURL           string
	AllowPrivateHosts bool
}

HubSpotDefaults configures runtime-only defaults for the HubSpot connector. It is intended for local development and test environments where HubSpot requests should be redirected to a mock service without exposing those knobs on the public data source contract.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager owns reusable PostgreSQL and MySQL connector pools for one process. Other connector types pass through the factory and are closed by their release function.

func NewManager

func NewManager(factory NewConnectorFunc, settings RuntimePoolSettings) (*Manager, error)

NewManager creates and starts a process-local connector runtime pool manager.

func (*Manager) Acquire

func (m *Manager) Acquire(
	ctx context.Context,
	identity RuntimeIdentity,
	configJSON, credentialsJSON []byte,
) (Connector, ReleaseFunc, error)

Acquire returns a connector and a release function. PostgreSQL and MySQL connectors are reused only for an exact runtime identity.

func (*Manager) Close

func (m *Manager) Close() error

Close prevents new acquisitions and closes every connector currently owned by the manager. It is safe to call more than once.

func (*Manager) Snapshot

func (m *Manager) Snapshot() RuntimePoolSnapshot

Snapshot returns aggregate cache and database/sql pool utilization.

type NewConnectorFunc

type NewConnectorFunc func(ctx context.Context, dsType model.DataSourceType, configJSON, credentialsJSON []byte) (Connector, error)

NewConnectorFunc is the signature for a connector factory function. It creates a connector for the given data source type with raw config and credentials payloads.

func NewConnectorWithBigQueryDefaults

func NewConnectorWithBigQueryDefaults(
	base NewConnectorFunc,
	defaults BigQueryDefaults,
) NewConnectorFunc

NewConnectorWithBigQueryDefaults applies runtime BigQuery defaults before delegating to the provided connector factory.

func NewConnectorWithHubSpotDefaults

func NewConnectorWithHubSpotDefaults(
	base NewConnectorFunc,
	defaults HubSpotDefaults,
) NewConnectorFunc

NewConnectorWithHubSpotDefaults applies runtime HubSpot defaults before delegating to the provided connector factory.

func NewConnectorWithPrivatePostgres

func NewConnectorWithPrivatePostgres(base NewConnectorFunc, endpoint PrivatePostgresEndpoint) NewConnectorFunc

NewConnectorWithPrivatePostgres grants only the configured tenant and source destination access to the pinned socket. Pool identities retain tenant scoping.

func NewConnectorWithPrivatePostgresPolicy

func NewConnectorWithPrivatePostgresPolicy(base NewConnectorFunc, policy PrivatePostgresPolicy) NewConnectorFunc

func NewConnectorWithSnowflakeDefaults

func NewConnectorWithSnowflakeDefaults(base NewConnectorFunc, defaults SnowflakeDefaults) NewConnectorFunc

NewConnectorWithSnowflakeDefaults selects an operator-authorized customer identity, or the separately configured organization-bound staging fixture.

func NewConnectorWithTracing

func NewConnectorWithTracing(base NewConnectorFunc) NewConnectorFunc

NewConnectorWithTracing wraps connector operations with safe OpenTelemetry spans.

func NewConnectorWithTransportPolicy

func NewConnectorWithTransportPolicy(base NewConnectorFunc, allowPlaintext bool) NewConnectorFunc

NewConnectorWithTransportPolicy carries an operator-only local policy through every execution role.

type PrivatePostgresEndpoint

type PrivatePostgresEndpoint struct {
	Authorize        func(context.Context) error
	MaxConns         int
	OrganizationSlug slug.Slug
	SourceSlug       slug.Slug
	Host             string
	Address          netip.AddrPort
}

PrivatePostgresEndpoint is deployment-owned routing, never customer source configuration.

type PrivatePostgresPolicy

type PrivatePostgresPolicy func(context.Context, slug.Slug, slug.Slug, model.DataSourceType, []byte, []byte) (PrivatePostgresEndpoint, error)

PrivatePostgresPolicy grants deployment-owned routing after checking the resource identity and payload.

type ReleaseFunc

type ReleaseFunc func() error

ReleaseFunc releases one acquired connector lease.

type ResourceMetadataObserver

type ResourceMetadataObserver interface {
	proofevidence.MetadataObserver
	MatchesResource(json.RawMessage, json.RawMessage, bool) bool
	Description() string
	AssessMetadata(json.RawMessage) (model.ProofVerdict, []model.ProofDiagnostic, error)
}

ResourceMetadataObserver owns resource admission and claim semantics alongside its native client. Shared services never interpret provider selectors.

func NewMetadataObserver

func NewMetadataObserver(plan proofevidence.MetadataPlan) (ResourceMetadataObserver, error)

NewMetadataObserver reconstructs trusted connector code, never executable routes from a delivery. Its regenerated plan must match the admitted plan.

type RuntimeIdentity

type RuntimeIdentity struct {
	OrganizationSlug  slug.Slug
	DataSourceSlug    slug.Slug
	DataSourceType    model.DataSourceType
	ConfigVersion     string
	CredentialVersion string
}

RuntimeIdentity identifies one reusable connector configuration without carrying credential material. Version values are opaque to the manager.

type RuntimePoolSettings

type RuntimePoolSettings struct {
	MaxEntries      int
	IdleTimeout     time.Duration
	MaxLifetime     time.Duration
	CleanupInterval time.Duration
}

RuntimePoolSettings controls the process-local cache of reusable SQL pools.

type RuntimePoolSnapshot

type RuntimePoolSnapshot struct {
	Entries            int
	Creating           int
	Retired            int
	ActiveLeases       int
	MaxEntries         int
	OpenConnections    int
	InUseConnections   int
	IdleConnections    int
	MaxOpenConnections int
	WaitCount          int64
	WaitDuration       time.Duration
	MaxIdleClosed      int64
	MaxIdleTimeClosed  int64
	MaxLifetimeClosed  int64
}

RuntimePoolSnapshot contains aggregate, tenant-safe process-local pool state.

type SnowflakeDefaults

type SnowflakeDefaults struct {
	WIFResolve          func(context.Context, slug.Slug, slug.Slug, string) (snowflakewif.Identity, error)
	WIFTokenFile        string
	WIFOrganizationSlug slug.Slug
	WIFSocketPath       string
}

SnowflakeDefaults configures deployment-owned Snowflake workload identity inputs. These values are applied after customer config normalization and are never persisted.

Directories

Path Synopsis
Package filedata provides shared file-format detection, CSV/JSON/spreadsheet parsing, and schema inference helpers used by file-backed data source connectors (FTP, Git).
Package filedata provides shared file-format detection, CSV/JSON/spreadsheet parsing, and schema inference helpers used by file-backed data source connectors (FTP, Git).
Package git provides a Git connector for Braidplane data sources.
Package git provides a Git connector for Braidplane data sources.
Package param provides utilities for template parameter substitution in query strings.
Package param provides utilities for template parameter substitution in query strings.
Package remotefile adapts provider-owned file transports to Braidplane's shared file connector execution contract.
Package remotefile adapts provider-owned file transports to Braidplane's shared file connector execution contract.
s3
Package s3 provides an S3-compatible object-store connector for Braidplane.
Package s3 provides an S3-compatible object-store connector for Braidplane.
sql
Package stripe implements bounded revenue reads from the Stripe API.
Package stripe implements bounded revenue reads from the Stripe API.

Jump to

Keyboard shortcuts

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