Skip to content

Streaming is a client library, where the input and output data are stored in Kafka clusters.

License

Notifications You must be signed in to change notification settings

flyaways/streaming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b9949c2 · Dec 15, 2023

History

14 Commits
Jun 2, 2018
May 28, 2018
Feb 27, 2018
Dec 15, 2023
Jun 2, 2018
Feb 27, 2018
Jun 2, 2018
Jun 2, 2018
Jun 2, 2018
Jun 2, 2018
Feb 27, 2018
Jun 2, 2018
Jun 2, 2018
Jun 2, 2018

Repository files navigation

streaming

Go Report Card LICENSE LICENSE

streaming

Streaming is a client library, where the input and output data are stored in Kafka clusters.

Introduction

Streaming is a library written for kafka streamming processor,.

Basic Usage

Installation

go get -u github.com/flyaways/streaming

Usage

Streaming Processor

package main

import (
	"log"
	"os"
	"os/signal"

	"github.com/Shopify/sarama"
	cluster "github.com/bsm/sarama-cluster"
	"github.com/flyaways/streaming"
)

func Processor(msg *sarama.ConsumerMessage, outTopic []string) ([]*sarama.ProducerMessage, error) {
	msgs := []*sarama.ProducerMessage{}
	if msg.Topic == "input-topic-2" {
		msgs = append(msgs, &sarama.ProducerMessage{
			Topic: outTopic[0],
			Key:   sarama.ByteEncoder(msg.Key),
			Value: sarama.ByteEncoder(msg.Value),
		})
	}
	return msgs, nil
}

func main() {
	if err := streaming.NewStreaming(
		[]string{"127.0.0.1:9092"},
		[]string{"input-topic1", "input-topic-2"},
		[]string{"output-topic1", "output-topic"},
		"flyaways-streaming-group",
		cluster.NewConfig(),
		Processor); err != nil {
		log.Panic(err)
	}

	signals := make(chan os.Signal, 1)
	signal.Notify(signals, os.Interrupt)
	<-signals
}

Credits

Licenses

https://www.apache.org/licenses/LICENSE-2.0

FOSSA Status

About

Streaming is a client library, where the input and output data are stored in Kafka clusters.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages