Documentation ¶
Index ¶
- Constants
- Variables
- func NewGormDbCreator(properties CockroachProperties) data.DbCreator
- func NewGormDialetor(di initDI) gorm.Dialector
- func NewPqErrorTranslator() data.ErrorTranslator
- func Use()
- type CockroachProperties
- type GormDbCreator
- type GormDialector
- type GormMigrator
- type PostgresErrorTranslator
- type TLS
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 NewPqErrorTranslator ¶
func NewPqErrorTranslator() data.ErrorTranslator
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 ¶
type GormDialector ¶
func NewGormDialectorWithConfig ¶
func NewGormDialectorWithConfig(config postgres.Config) *GormDialector
type GormMigrator ¶
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
type TLS ¶
type TLS struct { Enable bool `json:"enabled"` Certs certs.SourceProperties `json:"certs"` }
Click to show internal directories.
Click to hide internal directories.