Exemplo n.º 1
0
func (sinkManager *SinkManager) registerNewSyslogSink(appId string, syslogSinkUrl string) {
	parsedSyslogDrainUrl, err := sinkManager.urlBlacklistManager.CheckUrl(syslogSinkUrl)
	if err != nil {
		sinkManager.SendSyslogErrorToLoggregator(invalidSyslogUrlErrorMsg(appId, syslogSinkUrl, err), appId, syslogSinkUrl)
		return
	}

	syslogWriter, err := syslogwriter.NewWriter(parsedSyslogDrainUrl, appId, sinkManager.skipCertVerify)
	if err != nil {
		sinkManager.SendSyslogErrorToLoggregator(invalidSyslogUrlErrorMsg(appId, syslogSinkUrl, err), appId, syslogSinkUrl)
		return
	}

	syslogSink := syslog.NewSyslogSink(
		appId,
		syslogSinkUrl,
		sinkManager.logger,
		syslogWriter,
		sinkManager.SendSyslogErrorToLoggregator,
		sinkManager.dropsondeOrigin,
		sinkManager.sinkDropUpdateChannel,
	)

	sinkManager.RegisterSink(syslogSink)

}
Exemplo n.º 2
0
func (sinkManager *SinkManager) registerNewSyslogSink(appId string, syslogSinkURL string) {
	parsedSyslogDrainURL, err := sinkManager.urlBlacklistManager.CheckUrl(syslogSinkURL)
	if err != nil {
		sinkManager.SendSyslogErrorToLoggregator(invalidSyslogURLErrorMsg(appId, syslogSinkURL, err), appId)
		return
	}

	syslogWriter, err := syslogwriter.NewWriter(parsedSyslogDrainURL, appId, sinkManager.skipCertVerify, sinkManager.dialTimeout, sinkManager.sinkIOTimeout)
	if err != nil {
		logURL := fmt.Sprintf("%s://%s%s", parsedSyslogDrainURL.Scheme, parsedSyslogDrainURL.Host, parsedSyslogDrainURL.Path)
		sinkManager.SendSyslogErrorToLoggregator(invalidSyslogURLErrorMsg(appId, logURL, err), appId)
		return
	}

	syslogSink := syslog.NewSyslogSink(
		appId,
		parsedSyslogDrainURL,
		sinkManager.logger,
		sinkManager.messageDrainBufferSize,
		syslogWriter,
		sinkManager.SendSyslogErrorToLoggregator,
		sinkManager.dropsondeOrigin,
	)

	sinkManager.RegisterSink(syslogSink)

}
Exemplo n.º 3
0
import (
	"doppler/sinks/syslogwriter"

	"net/url"
	"reflect"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Writer", func() {

	It("returns an syslogWriter for syslog scheme", func() {
		outputUrl, _ := url.Parse("syslog://localhost:9999")
		w, err := syslogwriter.NewWriter(outputUrl, "appId", false)
		Expect(err).ToNot(HaveOccurred())
		writerType := reflect.TypeOf(w).String()
		Expect(writerType).To(Equal("*syslogwriter.syslogWriter"))
	})

	It("returns an tlsWriter for syslog-tls scheme", func() {
		outputUrl, _ := url.Parse("syslog-tls://localhost:9999")
		w, err := syslogwriter.NewWriter(outputUrl, "appId", false)
		Expect(err).ToNot(HaveOccurred())
		writerType := reflect.TypeOf(w).String()
		Expect(writerType).To(Equal("*syslogwriter.tlsWriter"))
	})

	It("returns an httpsWriter for https scheme", func() {
		outputUrl, _ := url.Parse("https://localhost:9999")
Exemplo n.º 4
0
import (
	"doppler/sinks/syslogwriter"
	"time"

	"net/url"
	"reflect"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Writer", func() {

	It("returns an syslogWriter for syslog scheme", func() {
		outputUrl, _ := url.Parse("syslog://localhost:9999")
		w, err := syslogwriter.NewWriter(outputUrl, "appId", false, 1*time.Second, 0)
		Expect(err).ToNot(HaveOccurred())
		writerType := reflect.TypeOf(w).String()
		Expect(writerType).To(Equal("*syslogwriter.syslogWriter"))
	})

	It("returns an tlsWriter for syslog-tls scheme", func() {
		outputUrl, _ := url.Parse("syslog-tls://localhost:9999")
		w, err := syslogwriter.NewWriter(outputUrl, "appId", false, 1*time.Second, 0)
		Expect(err).ToNot(HaveOccurred())
		writerType := reflect.TypeOf(w).String()
		Expect(writerType).To(Equal("*syslogwriter.tlsWriter"))
	})

	It("returns an httpsWriter for https scheme", func() {
		outputUrl, _ := url.Parse("https://localhost:9999")