encoder

package
v0.0.0-...-c73593d Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encoders

func Encoders() []string

Encoders return the list of encoders names

func GetCommonFormatKey

func GetCommonFormatKey(cf *types.CommonFormatEvent) string

GetCommonFormatKey concatenates common format key into string

func GetLatestSchemaCodec

func GetLatestSchemaCodec(service string, db string, table string, typ string) (goavro.Codec, *goavro.RecordSetter, error)

GetLatestSchemaCodec resolves schema and converts it to Avro codec and setter

func GetOutputSchemaName

func GetOutputSchemaName(service string, db string, table string) string

GetOutputSchemaName combines parameter into output topic name

func GetRowKey

func GetRowKey(s *types.TableSchema, row *[]interface{}) string

GetRowKey concatenates row primary key fields into string TODO: Should we encode into byte array instead?

func GetSchemaWebster

func GetSchemaWebster(namespace string, schemaName string, typ string) (*types.AvroSchema, error)

GetSchemaWebster makes a GET HTTP call to webster schema service to get the latest schema version for a given namespace and schema name.

func SchemaCodecHelper

func SchemaCodecHelper(avroSchema *types.AvroSchema) (goavro.Codec, *goavro.RecordSetter, error)

SchemaCodecHelper gets Avro codec and Avro record setter from schema structure

Types

type Encoder

type Encoder interface {
	Row(tp int, row *[]interface{}, seqNo uint64) ([]byte, error)
	CommonFormat(cf *types.CommonFormatEvent) ([]byte, error)
	EncodeSchema(seqNo uint64) ([]byte, error)
	UpdateCodec() error
	Type() string
	Schema() *types.TableSchema

	UnwrapEvent(data []byte, cfEvent *types.CommonFormatEvent) (payload []byte, err error)
	DecodeEvent(b []byte) (*types.CommonFormatEvent, error)
}

Encoder is unified interface to encode data from transit formats(row, common)

var Internal Encoder

Internal is encoder for intermediate buffer messages and message wrappers. Initialized in z.go

func Create

func Create(encType string, s string, d string, t string) (Encoder, error)

Create is a factory which create encoder of given type for given service, db, table

func InitEncoder

func InitEncoder(encType string, s string, d string, t string) (Encoder, error)

InitEncoder constructs encoder without updating schema

type GenTimeFunc

type GenTimeFunc func() int64

GenTimeFunc created to be able to return deterministic timestamp in test TODO: Come up with better day of doing this

var GenTime GenTimeFunc = genTime

GenTime is polymorphic function to be able to replace common format timestamp generator

type GetLatestSchemaFunc

type GetLatestSchemaFunc func(namespace string, schemaName string, typ string) (*types.AvroSchema, error)

GetLatestSchemaFunc is a type to implement schema resolver polymorphism

var GetLatestSchema GetLatestSchemaFunc = GetSchemaWebster

GetLatestSchema is the pointer to schema resolver

Jump to

Keyboard shortcuts

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