txn2/kubefwd

View on GitHub
pkg/fwdpub/fwdpub.go

Summary

Maintainability
A
0 mins
Test Coverage
package fwdpub

import (
    "fmt"
    "strings"
)

// Publisher
type Publisher struct {
    Output        bool
    PublisherName string
    ProducerName  string
}

// MakeProducer
func (p *Publisher) MakeProducer(producer string) Publisher {
    p.ProducerName = producer
    return *p
}

// Write
func (p *Publisher) Write(b []byte) (int, error) {
    outputString := string(b)
    outputString = strings.TrimSuffix(outputString, "\n")

    if p.Output {
        fmt.Printf("Out: %s, %s, %s\n", p.PublisherName, p.ProducerName, outputString)
    }
    return 0, nil
}