dotgen

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

README

DotGen

DotGen is a package for generating DOT files that describe a Goka GroupGraph.

Example


The following code is a working example on how to generate a DOT using DotGen.

package main

import (
	"flag"
	"log"
	"os"

	"github.com/lovoo/goka"
	"github.com/lovoo/goka-tools/dotgen"
	"github.com/lovoo/goka/codec"
)

var (
	brokers = []string{"localhost:9092"}
	output  = flag.String("output", "stdout", "file to output dot to. stdout if not set")
)

func main() {
	flag.Parse()

	out, err := os.Create(*output)
	if err != nil {
		log.Fatalf("Error opening output file")
	}
	defer out.Close()
	tree := dotgen.NewTree(out)

	// create a sample processor
	_, err = goka.NewProcessor(brokers, goka.DefineGroup(
		goka.Group("sample-processor"),
		goka.Input("sample-input-topic", new(codec.String), func(ctx goka.Context, msg interface{}) {}),
		goka.Output("sample-output-topic", new(codec.String)),
		goka.Persist(new(codec.String)),
	),
		// the processor option WithGroupGraphHook obtain the group graph once the processor is started
		goka.WithGroupGraphHook(tree.TrackGroupGraph), goka.WithClientID("sample-processor"),
	)

	if err != nil {
		log.Fatalf("Error creating processor from goka: %v", err)
	}

	tree.Render()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Processor

type Processor struct {
	ID        string
	Name      string
	Output    []*Topic
	Input     []*Topic
	LoopCodec string
	Join      []*Topic
	Lookup    []*Topic
	Persist   *Topic
}

Processor represents a goka processor

type Topic

type Topic struct {
	ID      string
	Name    string
	Codec   string
	IsTable bool
}

Topic represents a kafka topic (stream or table)

type Tree

type Tree struct {
	Processors map[string]*Processor
	Topics     map[string]*Topic
	// contains filtered or unexported fields
}

Tree stores all processors and topics to be rendered together in one graph

func NewTree

func NewTree(out io.Writer) *Tree

NewTree creates a new tree for an output writer

func (*Tree) Render

func (t *Tree) Render()

Render renders the different parts of the dot graph

func (*Tree) TrackGroupGraph

func (t *Tree) TrackGroupGraph(gg *goka.GroupGraph)

Jump to

Keyboard shortcuts

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