common

package
v0.0.0-...-a4119a3 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: AGPL-3.0 Imports: 11 Imported by: 2 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 (
	ErrorInfoDomain = "peerdb.io"
	// MaxTablesInErrorDetails bounds table lists carried in gRPC status metadata.
	// Rich gRPC errors are transported in response headers/trailers, which have
	// substantially smaller limits than response bodies.
	MaxTablesInErrorDetails = 20

	ErrorInfoReasonMirror                 = "MIRROR"
	ErrorInfoReasonSourceTableMissing     = "SOURCE_TABLE_MISSING"
	ErrorInfoReasonTablesNotInPublication = "TABLES_NOT_IN_PUBLICATION"
	ErrorInfoReasonSourceValidationFailed = "SOURCE_VALIDATION_FAILED"
	ErrorInfoReasonSourceConnectionFailed = "SOURCE_CONNECTION_FAILED"

	ErrorMetadataOffendingField = "offendingField"
	ErrorMetadataPublication    = "publication"
	ErrorMetadataTableCount     = "tableCount"
)

gRPC ErrorInfo constants

View Source
const (
	OrgIdTag     = "org_id"
	ServiceIdTag = "service_id"
	PipeIdTag    = "pipe_id"
	PipeNameTag  = "pipe_name"
)
View Source
const MinSyncCronGap = time.Minute

MinSyncCronGap is the shortest allowed gap between two consecutive fires of a sync cron schedule.

Variables

This section is empty.

Functions

func CreateTlsConfig

func CreateTlsConfig(
	minVersion uint16, rootCAs *string, host string, tlsHost string, skipCertVerification bool,
	clientCert *ClientCertificate,
) (*tls.Config, error)

func CreateTlsConfigFromRootCAString

func CreateTlsConfigFromRootCAString(
	minVersion uint16,
	rootCAs string,
	host string,
	tlsHost string,
	skipCertVerification bool,
) (*tls.Config, error)

CreateTlsConfigFromRootCAString adapts CreateTlsConfig for callers that pass rootCAs as a string rather than *string (e.g. mongo ClientConfig). Empty string is treated as no custom CA.

func HeartbeatRoutine

func HeartbeatRoutine(
	ctx context.Context,
	message func() string,
) func()

func Interval

func Interval(
	ctx context.Context,
	freq time.Duration,
	fn func(),
) func()

func ParseNumericTypmod

func ParseNumericTypmod(typmod int32) (int16, int16)

ParseNumericTypmod reverses what make_numeric_typmod of Postgres does: https://github.com/postgres/postgres/blob/21912e3c0262e2cfe64856e028799d6927862563/src/backend/utils/adt/numeric.c#L897

func ParseSyncCron

func ParseSyncCron(expr string) (cron.Schedule, error)

ParseSyncCron parses a standard 5-field cron expression (or a descriptor such as @hourly). Schedules are evaluated in UTC unless the expression carries its own CRON_TZ= prefix.

func QuoteIdentifier

func QuoteIdentifier(name string) string

QuoteIdentifier quotes an "identifier" (e.g. a table or a column name) to be used as part of an SQL statement. For example:

tblname := "my_table"
data := "my_data"
quoted := common.QuoteIdentifier(tblname)
err := db.Exec(fmt.Sprintf("INSERT INTO %s VALUES ($1)", quoted), data)

Any double quotes in name will be escaped. The quoted identifier will be case-sensitive when used in a query. If the input string contains a zero byte, the result will be truncated immediately before it.

func QuoteMySQLIdentifier

func QuoteMySQLIdentifier(name string) string

func RandomString

func RandomString(n int) string

Types

type ClientCertificate

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

ClientCertificate is a PEM-encoded client certificate and its private key, for mutual TLS.

func NewClientCertificate

func NewClientCertificate(certificate string, privateKey string) (*ClientCertificate, error)

NewClientCertificate requires both the certificate and private key to be non-empty.

type QualifiedTable

type QualifiedTable struct {
	Namespace string // schema in PG, database in MySQL/Mongo
	Table     string // table or collection
}

func ParseTableIdentifier

func ParseTableIdentifier(tableIdentifier string) (*QualifiedTable, error)

ParseTableIdentifier parses a table name into namespace and table name.

func (QualifiedTable) MySQL

func (t QualifiedTable) MySQL() string

func (QualifiedTable) String

func (t QualifiedTable) String() string

type ReplicaIdentifierInUseError

type ReplicaIdentifierInUseError struct {
	Id string
}

func NewReplicaIdentifierInUseError

func NewReplicaIdentifierInUseError(id string) *ReplicaIdentifierInUseError

func (*ReplicaIdentifierInUseError) Error

type SourceTablesMissingError

type SourceTablesMissingError struct {
	Tables []QualifiedTable
}

func NewSourceTablesMissingError

func NewSourceTablesMissingError(tables []QualifiedTable) *SourceTablesMissingError

func (*SourceTablesMissingError) Error

func (e *SourceTablesMissingError) Error() string

type TablesNotInPublicationError

type TablesNotInPublicationError struct {
	Publication string
	Tables      []QualifiedTable
}

func NewTablesNotInPublicationError

func NewTablesNotInPublicationError(publication string, tables []QualifiedTable) *TablesNotInPublicationError

func (*TablesNotInPublicationError) Error

Jump to

Keyboard shortcuts

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