Skip to content

andreaTP/debezium-smt-go-pdk

Repository files navigation

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/andreaTP/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/andreaTP/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.GetInt) 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, SetInt ...) should be returned as the result of the process function.

About

[POC] Go PDK to write SMT transformations in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published