Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 979 Bytes

File metadata and controls

45 lines (31 loc) · 979 Bytes

Build your own function to handle ChangeStream event.

Requirements

Coding

write your code in the handlerEvent function in lib.go, and do not edit the entry.go

// implemented by the user
func handlerEvent(event model.ChangeStreamEvent) error {
	// fmt.Printf("event: %#+v\n", event)
	data, err := json.MarshalIndent(event, "", "\t")
	if err != nil {
		return err
	}
	fmt.Printf("event:\n%s\n", string(data))

	if event.OperationType == "delete" {
		return errors.New("unsuppored op_type: Delete")
	}

	return nil
}

Build

❯ make build
go generate model/model.go
tinygo build -o target/example_wasm_go_event_handler_lib.wasm -target wasi
❯ tree target/
target/
└── example_wasm_go_event_handler_lib.wasm

0 directories, 1 file

Once the .wasm file is built, you can deploy it to the trigger service