numaflow-go

module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: Apache-2.0

README

Numaflow Golang SDK

This SDK provides the interfaces to implement Numaflow User Defined Functions or Sinks in Golang.

Implement User Defined Functions

package main

import (
	"context"

	funcsdk "github.com/numaproj/numaflow-go/function"
)

func handle(ctx context.Context, key, msg []byte) (funcsdk.Messages, error) {
	return funcsdk.MessagesBuilder().Append(funcsdk.MessageToAll(msg)), nil
}

func main() {
	funcsdk.Start(context.Background(), handle)
}

Implement User Defined Sinks

package main

import (
	"context"
	"fmt"

	sinksdk "github.com/numaproj/numaflow-go/sink"
)

func handle(ctx context.Context, msgs []sinksdk.Message) (sinksdk.Responses, error) {
	result := sinksdk.ResponsesBuilder()
	for _, m := range msgs {
		fmt.Println(string(m.Payload))
		result = result.Append(sinksdk.ResponseOK(m.ID))
	}
	return result, nil
}

func main() {
	sinksdk.Start(context.Background(), handle)
}

Directories

Path Synopsis
examples
Package golang provides an interface to write UDF in golang which will be exposed over HTTP.
Package golang provides an interface to write UDF in golang which will be exposed over HTTP.
pkg
apis/proto/function/v1/funcmock
Package funcmock is a generated GoMock package.
Package funcmock is a generated GoMock package.

Jump to

Keyboard shortcuts

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