Documentation ¶
Overview ¶
Implements decoding of Postgres types into Golang, using mappings that are generated from pgtype.
The Decoder provides consistent scanners across pgsink components, ensuring the logical subscription decodes Postgres values into the same types as the import.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decoder ¶
func NewDecoder ¶
func NewDecoder(mappings []TypeMapping) Decoder
type Scanner ¶
type Scanner interface { // Scan satisfies the sql.Scanner interface, allowing us to pass instances to sql.DB // method calls Scan(src interface{}) error // Value is the common interface to all the pgtype constructs pgtype.Value }
Scanner defines what pgtypes must support to be included in the decoder. It is used to filter available types in the generation of mappings.
type TypeMapping ¶
type TypeMapping struct { Name string // human recognisable type-name OID uint32 // Postgres type OID Scanner Scanner // scanner for parsing type from database Empty interface{} // Golang empty type produced by the scanner }
TypeMapping binds a Postgres type, denoted by the name and oid, to a Golang type. It is used as a database scanner, but with a restricted interface that ensures Get()ing the scanned value can return only the type allowed by this mapping.
func (TypeMapping) NewEmpty ¶
func (t TypeMapping) NewEmpty() interface{}
NewEmpty allocates a new destination for a given type-mapping. This can be used with the scanner's AssignTo method to construct results of the correct type.
It will return a handle to the exact type of Empty. This means something like a string will be given as a *string, likewise with *[]string, etc.
func (TypeMapping) NewScanner ¶
func (t TypeMapping) NewScanner() Scanner
NewScanner initialises a new scanner, using the mapping Scanner as a template
type UnregisteredType ¶
type UnregisteredType struct {
OID uint32
}
UnregisteredType is returned whenever we see a Postgres OID that has no associated type mapping. How we handle this depends on the caller.
func (*UnregisteredType) Error ¶
func (e *UnregisteredType) Error() string