cockroach

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CockroachPropertiesPrefix = "data.cockroach"
)

Variables

View Source
var Module = &bootstrap.Module{
	Name:       "cockroach",
	Precedence: bootstrap.DatabasePrecedence,
	Options: []fx.Option{
		fx.Provide(NewGormDialetor,
			BindCockroachProperties,
			NewGormDbCreator,
			pqErrorTranslatorProvider(),
		),
	},
}

Functions

func NewGormDbCreator

func NewGormDbCreator(properties CockroachProperties) data.DbCreator

func NewGormDialetor

func NewGormDialetor(di initDI) gorm.Dialector

func NewPqErrorTranslator

func NewPqErrorTranslator() data.ErrorTranslator

func Use

func Use()

Types

type CockroachProperties

type CockroachProperties struct {
	//Enabled       bool                               `json:"enabled"`
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Database string `json:"database"`
	Username string `json:"username"`
	Password string `json:"password"`
	SslMode  string `json:"sslmode"`
	Tls      TLS    `json:"tls"`
}

func BindCockroachProperties

func BindCockroachProperties(ctx *bootstrap.ApplicationContext) CockroachProperties

BindCockroachProperties create and bind SessionProperties, with a optional prefix

func NewCockroachProperties

func NewCockroachProperties() *CockroachProperties

NewCockroachProperties create a CockroachProperties with default values

type GormDbCreator

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

func (*GormDbCreator) CreateDatabaseIfNotExist

func (g *GormDbCreator) CreateDatabaseIfNotExist(ctx context.Context, db *gorm.DB) error

type GormDialector

type GormDialector struct {
	postgres.Dialector
}

func NewGormDialectorWithConfig

func NewGormDialectorWithConfig(config postgres.Config) *GormDialector

func (GormDialector) Migrator

func (d GormDialector) Migrator(db *gorm.DB) gorm.Migrator

type GormMigrator

type GormMigrator struct {
	postgres.Migrator
}

GormMigrator Inverted index support: for now, use PostgreSQL-compatible syntax: https://www.cockroachlabs.com/docs/v20.2/inverted-indexes#creation

func NewGormMigrator

func NewGormMigrator(db *gorm.DB, dialector gorm.Dialector) *GormMigrator

type PostgresErrorTranslator

type PostgresErrorTranslator struct{}

PostgresErrorTranslator implements data.ErrorTranslator it translates pq.Error and pgconn.PgError to data.DataError Note: cockroach uses gorm.io/driver/postgres, which internally uses github.com/jackc/pgx Ref: - Postgres Error: https://www.postgresql.org/docs/11/protocol-error-fields.html - Postgres Error Code: https://www.postgresql.org/docs/11/errcodes-appendix.html

func (PostgresErrorTranslator) Order

func (t PostgresErrorTranslator) Order() int

func (PostgresErrorTranslator) Translate

func (t PostgresErrorTranslator) Translate(_ context.Context, err error) error

type TLS

type TLS struct {
	Enable bool                   `json:"enabled"`
	Certs  certs.SourceProperties `json:"certs"`
}

Jump to

Keyboard shortcuts

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