Skip to content

Latest commit

 

History

History
60 lines (39 loc) · 1.55 KB

Readme.md

File metadata and controls

60 lines (39 loc) · 1.55 KB

Debezium SMT Go PDK

This library can be used to write Debezium SMT in Go.

Install

Include the library with Go get:

go get github.com/debezium/debezium-smt-go-pdk

Reference Documentation

You can find the reference documentation for this library on pkg.go.dev.

Getting Started

A simple Debezium SMT written in Go should include a process function exported like:

package main

import (
	"github.com/debezium/debezium-smt-go-pdk"
)

//export process
func process(proxyPtr uint32) uint32 {
	return debezium.SetNull()
}

func main() {}

You can compile the program using TinyGo (version > 0.34.0):

tinygo build --no-debug -target=wasm-unknown -o smt.wasm main.go

Data In/Out

For efficiency reasons the full content of the record is not transferred to the Go function, but it can be lazyily accessed using PDK functionalities:

debezium.GetString(debezium.Get(proxyPtr, "value.op"))

where debezium.Get is used to access the required field with a familiar dot(.) syntax, and debezium.GetString (or debezium.IsNull, debezium.GetInt32, etc.) materialize the value.

Similarly, returning a value to Debezium is performed using the PDK functionalities:

return debezium.SetString("foobar")

the value returned by the Set function (or SetNull, SetBool, SetString ...) should be returned as the result of the process function.