postgres

package
v0.0.396 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Package__sfr1nt = &core.Package{
		PackageName:         "namespacelabs.dev/foundation/universe/db/postgres",
		PackageDependencies: []string{"namespacelabs.dev/foundation/std/monitoring/tracing"},
	}

	Provider__sfr1nt = core.Provider{
		Package:     Package__sfr1nt,
		Instantiate: makeDeps__sfr1nt,
	}
)
View Source
var File_universe_db_postgres_database_proto protoreflect.FileDescriptor
View Source
var File_universe_db_postgres_provider_proto protoreflect.FileDescriptor

Functions

func ErrorIsRetryable added in v0.0.255

func ErrorIsRetryable(err error) bool

func PgErrCode added in v0.0.355

func PgErrCode(err error) string

Returns the error code (to be compared to pgerrcode.* constants).

func ReturnFromReadWriteTx added in v0.0.180

func ReturnFromReadWriteTx[T any](ctx context.Context, db *DB, b backoff.BackOff, f func(context.Context, pgx.Tx) (T, error)) (T, error)

func ReturnFromTx added in v0.0.100

func ReturnFromTx[T any](ctx context.Context, db *DB, txoptions pgx.TxOptions, f func(context.Context, pgx.Tx) (T, error)) (T, error)

Types

type ConfigOverrides added in v0.0.349

type ConfigOverrides struct {
	MaxConns        int32
	MaxConnIdleTime time.Duration
}

type ConnUri added in v0.0.355

type ConnUri string

Workaround the fact that foundation doesn't know about primitive types.

func ProvideDatabaseReference added in v0.0.355

func ProvideDatabaseReference(ctx context.Context, args *DatabaseReferenceArgs, deps ExtensionDeps) (ConnUri, error)

type DB

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

func ConnectToResource added in v0.0.114

func ConnectToResource(ctx context.Context, res *resources.Parsed, resourceRef string, tp trace.TracerProvider, client string, overrides *ConfigOverrides) (*DB, error)

Connect to a Postgres Database resource.

func NewDatabaseFromConnectionUri added in v0.0.336

func NewDatabaseFromConnectionUri(ctx context.Context, db *postgrespb.DatabaseInstance, connuri string, tp trace.TracerProvider, client string) (*DB, error)

func NewDatabaseFromConnectionUriWithOverrides added in v0.0.349

func NewDatabaseFromConnectionUriWithOverrides(ctx context.Context, db *postgrespb.DatabaseInstance, connuri string, tp trace.TracerProvider, client string, overrides *ConfigOverrides) (*DB, error)

func ProvideDatabase added in v0.0.115

func ProvideDatabase(ctx context.Context, db *DatabaseArgs, deps ExtensionDeps) (*DB, error)

func (DB) Close added in v0.0.319

func (db DB) Close() error

func (DB) Exec

func (db DB) Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)

func (DB) PgxPool added in v0.0.341

func (db DB) PgxPool() *pgxpool.Pool

func (DB) Query

func (db DB) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)

func (DB) QueryRow

func (db DB) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row

func (DB) SendBatch added in v0.0.303

func (db DB) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults

type Database

type Database struct {
	Name        string                `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	SchemaFile  *types.Resource       `protobuf:"bytes,2,opt,name=schema_file,json=schemaFile,proto3" json:"schema_file,omitempty"`
	HostedAt    *Database_Endpoint    `protobuf:"bytes,3,opt,name=hosted_at,json=hostedAt,proto3" json:"hosted_at,omitempty"`
	Credentials *Database_Credentials `protobuf:"bytes,4,opt,name=credentials,proto3" json:"credentials,omitempty"`
	// contains filtered or unexported fields
}

func (*Database) Descriptor deprecated

func (*Database) Descriptor() ([]byte, []int)

Deprecated: Use Database.ProtoReflect.Descriptor instead.

func (*Database) GetCredentials

func (x *Database) GetCredentials() *Database_Credentials

func (*Database) GetHostedAt

func (x *Database) GetHostedAt() *Database_Endpoint

func (*Database) GetName

func (x *Database) GetName() string

func (*Database) GetSchemaFile

func (x *Database) GetSchemaFile() *types.Resource

func (*Database) ProtoMessage

func (*Database) ProtoMessage()

func (*Database) ProtoReflect

func (x *Database) ProtoReflect() protoreflect.Message

func (*Database) Reset

func (x *Database) Reset()

func (*Database) String

func (x *Database) String() string

type DatabaseArgs added in v0.0.115

type DatabaseArgs struct {
	Client           string               `protobuf:"bytes,7,opt,name=client,proto3" json:"client,omitempty"`
	ResourceRef      string               `protobuf:"bytes,3,opt,name=resource_ref,json=resourceRef,proto3" json:"resource_ref,omitempty"`
	MaxConns         int32                `protobuf:"varint,4,opt,name=max_conns,json=maxConns,proto3" json:"max_conns,omitempty"` // Set if > 0.
	MaxConnsFromEnv  string               `protobuf:"bytes,6,opt,name=max_conns_from_env,json=maxConnsFromEnv,proto3" json:"max_conns_from_env,omitempty"`
	MaxConnsIdleTime *durationpb.Duration `protobuf:"bytes,5,opt,name=max_conns_idle_time,json=maxConnsIdleTime,proto3" json:"max_conns_idle_time,omitempty"`
	// contains filtered or unexported fields
}

func (*DatabaseArgs) Descriptor deprecated added in v0.0.115

func (*DatabaseArgs) Descriptor() ([]byte, []int)

Deprecated: Use DatabaseArgs.ProtoReflect.Descriptor instead.

func (*DatabaseArgs) GetClient added in v0.0.374

func (x *DatabaseArgs) GetClient() string

func (*DatabaseArgs) GetMaxConns added in v0.0.349

func (x *DatabaseArgs) GetMaxConns() int32

func (*DatabaseArgs) GetMaxConnsFromEnv added in v0.0.374

func (x *DatabaseArgs) GetMaxConnsFromEnv() string

func (*DatabaseArgs) GetMaxConnsIdleTime added in v0.0.374

func (x *DatabaseArgs) GetMaxConnsIdleTime() *durationpb.Duration

func (*DatabaseArgs) GetResourceRef added in v0.0.115

func (x *DatabaseArgs) GetResourceRef() string

func (*DatabaseArgs) ProtoMessage added in v0.0.115

func (*DatabaseArgs) ProtoMessage()

func (*DatabaseArgs) ProtoReflect added in v0.0.115

func (x *DatabaseArgs) ProtoReflect() protoreflect.Message

func (*DatabaseArgs) Reset added in v0.0.115

func (x *DatabaseArgs) Reset()

func (*DatabaseArgs) String added in v0.0.115

func (x *DatabaseArgs) String() string

type DatabaseReferenceArgs added in v0.0.355

type DatabaseReferenceArgs struct {
	ClusterRef string `protobuf:"bytes,1,opt,name=cluster_ref,json=clusterRef,proto3" json:"cluster_ref,omitempty"`
	Database   string `protobuf:"bytes,2,opt,name=database,proto3" json:"database,omitempty"`
	// contains filtered or unexported fields
}

func (*DatabaseReferenceArgs) Descriptor deprecated added in v0.0.355

func (*DatabaseReferenceArgs) Descriptor() ([]byte, []int)

Deprecated: Use DatabaseReferenceArgs.ProtoReflect.Descriptor instead.

func (*DatabaseReferenceArgs) GetClusterRef added in v0.0.355

func (x *DatabaseReferenceArgs) GetClusterRef() string

func (*DatabaseReferenceArgs) GetDatabase added in v0.0.355

func (x *DatabaseReferenceArgs) GetDatabase() string

func (*DatabaseReferenceArgs) ProtoMessage added in v0.0.355

func (*DatabaseReferenceArgs) ProtoMessage()

func (*DatabaseReferenceArgs) ProtoReflect added in v0.0.355

func (x *DatabaseReferenceArgs) ProtoReflect() protoreflect.Message

func (*DatabaseReferenceArgs) Reset added in v0.0.355

func (x *DatabaseReferenceArgs) Reset()

func (*DatabaseReferenceArgs) String added in v0.0.355

func (x *DatabaseReferenceArgs) String() string

type Database_Credentials

type Database_Credentials struct {
	User     *Database_Credentials_Secret `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	Password *Database_Credentials_Secret `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
	// contains filtered or unexported fields
}

func (*Database_Credentials) Descriptor deprecated

func (*Database_Credentials) Descriptor() ([]byte, []int)

Deprecated: Use Database_Credentials.ProtoReflect.Descriptor instead.

func (*Database_Credentials) GetPassword

func (*Database_Credentials) GetUser

func (*Database_Credentials) ProtoMessage

func (*Database_Credentials) ProtoMessage()

func (*Database_Credentials) ProtoReflect

func (x *Database_Credentials) ProtoReflect() protoreflect.Message

func (*Database_Credentials) Reset

func (x *Database_Credentials) Reset()

func (*Database_Credentials) String

func (x *Database_Credentials) String() string

type Database_Credentials_Secret

type Database_Credentials_Secret struct {

	// Only set one of these fields.
	Value    string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"`
	FromPath string `protobuf:"bytes,2,opt,name=from_path,json=fromPath,proto3" json:"from_path,omitempty"`
	// contains filtered or unexported fields
}

func (*Database_Credentials_Secret) Descriptor deprecated

func (*Database_Credentials_Secret) Descriptor() ([]byte, []int)

Deprecated: Use Database_Credentials_Secret.ProtoReflect.Descriptor instead.

func (*Database_Credentials_Secret) GetFromPath

func (x *Database_Credentials_Secret) GetFromPath() string

func (*Database_Credentials_Secret) GetValue

func (x *Database_Credentials_Secret) GetValue() string

func (*Database_Credentials_Secret) ProtoMessage

func (*Database_Credentials_Secret) ProtoMessage()

func (*Database_Credentials_Secret) ProtoReflect

func (*Database_Credentials_Secret) Reset

func (x *Database_Credentials_Secret) Reset()

func (*Database_Credentials_Secret) String

func (x *Database_Credentials_Secret) String() string

type Database_Endpoint

type Database_Endpoint struct {
	Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
	Port    uint32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
	// contains filtered or unexported fields
}

func (*Database_Endpoint) Descriptor deprecated

func (*Database_Endpoint) Descriptor() ([]byte, []int)

Deprecated: Use Database_Endpoint.ProtoReflect.Descriptor instead.

func (*Database_Endpoint) GetAddress

func (x *Database_Endpoint) GetAddress() string

func (*Database_Endpoint) GetPort

func (x *Database_Endpoint) GetPort() uint32

func (*Database_Endpoint) ProtoMessage

func (*Database_Endpoint) ProtoMessage()

func (*Database_Endpoint) ProtoReflect

func (x *Database_Endpoint) ProtoReflect() protoreflect.Message

func (*Database_Endpoint) Reset

func (x *Database_Endpoint) Reset()

func (*Database_Endpoint) String

func (x *Database_Endpoint) String() string

type ExtensionDeps added in v0.0.115

type ExtensionDeps struct {
	OpenTelemetry tracing.DeferredTracerProvider
}

Dependencies that are instantiated once for the lifetime of the extension.

type Factory added in v0.0.291

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

func ProvideFactory added in v0.0.291

func ProvideFactory(ctx context.Context, args *FactoryArgs, deps ExtensionDeps) (Factory, error)

func (Factory) Provide added in v0.0.291

func (f Factory) Provide(ctx context.Context, ref string) (*DB, error)

type FactoryArgs added in v0.0.291

type FactoryArgs struct {
	Client string `protobuf:"bytes,1,opt,name=client,proto3" json:"client,omitempty"`
	// contains filtered or unexported fields
}

func (*FactoryArgs) Descriptor deprecated added in v0.0.291

func (*FactoryArgs) Descriptor() ([]byte, []int)

Deprecated: Use FactoryArgs.ProtoReflect.Descriptor instead.

func (*FactoryArgs) GetClient added in v0.0.374

func (x *FactoryArgs) GetClient() string

func (*FactoryArgs) ProtoMessage added in v0.0.291

func (*FactoryArgs) ProtoMessage()

func (*FactoryArgs) ProtoReflect added in v0.0.291

func (x *FactoryArgs) ProtoReflect() protoreflect.Message

func (*FactoryArgs) Reset added in v0.0.291

func (x *FactoryArgs) Reset()

func (*FactoryArgs) String added in v0.0.291

func (x *FactoryArgs) String() string

type InstantiatedDatabase

type InstantiatedDatabase struct {
	PackageName string                            `protobuf:"bytes,1,opt,name=package_name,json=packageName,proto3" json:"package_name,omitempty"`
	Credentials *InstantiatedDatabase_Credentials `protobuf:"bytes,2,opt,name=credentials,proto3" json:"credentials,omitempty"`
	Database    []*Database                       `protobuf:"bytes,3,rep,name=database,proto3" json:"database,omitempty"`
	// contains filtered or unexported fields
}

This type represents a fully formed database. This is an internal type, used for internal configuration.

func (*InstantiatedDatabase) Descriptor deprecated

func (*InstantiatedDatabase) Descriptor() ([]byte, []int)

Deprecated: Use InstantiatedDatabase.ProtoReflect.Descriptor instead.

func (*InstantiatedDatabase) GetCredentials

func (*InstantiatedDatabase) GetDatabase

func (x *InstantiatedDatabase) GetDatabase() []*Database

func (*InstantiatedDatabase) GetPackageName

func (x *InstantiatedDatabase) GetPackageName() string

func (*InstantiatedDatabase) ProtoMessage

func (*InstantiatedDatabase) ProtoMessage()

func (*InstantiatedDatabase) ProtoReflect

func (x *InstantiatedDatabase) ProtoReflect() protoreflect.Message

func (*InstantiatedDatabase) Reset

func (x *InstantiatedDatabase) Reset()

func (*InstantiatedDatabase) String

func (x *InstantiatedDatabase) String() string

type InstantiatedDatabase_Credentials

type InstantiatedDatabase_Credentials struct {
	SecretName         string `protobuf:"bytes,1,opt,name=secret_name,json=secretName,proto3" json:"secret_name,omitempty"`
	SecretMountPath    string `protobuf:"bytes,2,opt,name=secret_mount_path,json=secretMountPath,proto3" json:"secret_mount_path,omitempty"`
	SecretResourceName string `protobuf:"bytes,3,opt,name=secret_resource_name,json=secretResourceName,proto3" json:"secret_resource_name,omitempty"`
	// contains filtered or unexported fields
}

func (*InstantiatedDatabase_Credentials) Descriptor deprecated

func (*InstantiatedDatabase_Credentials) Descriptor() ([]byte, []int)

Deprecated: Use InstantiatedDatabase_Credentials.ProtoReflect.Descriptor instead.

func (*InstantiatedDatabase_Credentials) GetSecretMountPath

func (x *InstantiatedDatabase_Credentials) GetSecretMountPath() string

func (*InstantiatedDatabase_Credentials) GetSecretName

func (x *InstantiatedDatabase_Credentials) GetSecretName() string

func (*InstantiatedDatabase_Credentials) GetSecretResourceName

func (x *InstantiatedDatabase_Credentials) GetSecretResourceName() string

func (*InstantiatedDatabase_Credentials) ProtoMessage

func (*InstantiatedDatabase_Credentials) ProtoMessage()

func (*InstantiatedDatabase_Credentials) ProtoReflect

func (*InstantiatedDatabase_Credentials) Reset

func (*InstantiatedDatabase_Credentials) String

type InstantiatedDatabases

type InstantiatedDatabases struct {
	Instantiated []*InstantiatedDatabase `protobuf:"bytes,1,rep,name=instantiated,proto3" json:"instantiated,omitempty"`
	// contains filtered or unexported fields
}

func (*InstantiatedDatabases) Descriptor deprecated

func (*InstantiatedDatabases) Descriptor() ([]byte, []int)

Deprecated: Use InstantiatedDatabases.ProtoReflect.Descriptor instead.

func (*InstantiatedDatabases) GetInstantiated

func (x *InstantiatedDatabases) GetInstantiated() []*InstantiatedDatabase

func (*InstantiatedDatabases) ProtoMessage

func (*InstantiatedDatabases) ProtoMessage()

func (*InstantiatedDatabases) ProtoReflect

func (x *InstantiatedDatabases) ProtoReflect() protoreflect.Message

func (*InstantiatedDatabases) Reset

func (x *InstantiatedDatabases) Reset()

func (*InstantiatedDatabases) String

func (x *InstantiatedDatabases) String() string

type TransactionError added in v0.0.182

type TransactionError struct {
	InternalErr error
}

func (TransactionError) Error added in v0.0.182

func (p TransactionError) Error() string

func (TransactionError) Unwrap added in v0.0.182

func (p TransactionError) Unwrap() error

Jump to

Keyboard shortcuts

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