encoder

package
v1.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ZeroTime = time.Time{}.In(time.UTC)

ZeroTime in UTC

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, input string, output string, version int) (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, input string, output string, version int) (string, error)

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 SchemaCodecHelper

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

SchemaCodecHelper gets Avro codec and Avro record setter from schema structure

func WrapEvent

func WrapEvent(outputFormat string, key string, bd []byte, seqno uint64) ([]byte, error)

WrapEvent prepend provided payload with CommonFormat like event

Types

type Encoder

type Encoder interface {
	Row(tp int, row *[]interface{}, seqNo uint64, ts time.Time) ([]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, svc, sdb, tbl, input string, output string, version int) (Encoder, error)

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

func InitEncoder

func InitEncoder(encType, svc, sdb, tbl, input string, output string, version int) (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

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