From 7fc9a0e67a13ac3c15fe9c8630abac4508a96bdf Mon Sep 17 00:00:00 2001 From: jakthom Date: Fri, 23 Sep 2022 00:59:44 -0400 Subject: [PATCH] start stubbing out datadog sink --- Makefile | 2 +- go.mod | 2 ++ go.sum | 4 ++++ pkg/sink/datadog.go | 52 +++++++++++++++++++++++++++++++++++++++++++++ pkg/sink/sink.go | 1 + 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 pkg/sink/datadog.go diff --git a/Makefile b/Makefile index c5679888..d9651d15 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help run bootstrap bootstrap-destinations build-docker buildx-deploy test-cover-pkg +.PHONY: help run build bootstrap bootstrap-destinations build-docker buildx-deploy test-cover-pkg S=silverton REGISTRY:=us-east1-docker.pkg.dev/silverton-io/docker VERSION:=$(shell cat .VERSION) diff --git a/go.mod b/go.mod index 235dd53d..1477e111 100644 --- a/go.mod +++ b/go.mod @@ -42,6 +42,8 @@ require ( cloud.google.com/go/compute v1.1.0 // indirect cloud.google.com/go/iam v0.1.1 // indirect github.com/ClickHouse/clickhouse-go v1.5.4 // indirect + github.com/DataDog/datadog-api-client-go/v2 v2.2.0 // indirect + github.com/DataDog/zstd v1.5.0 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.3.0 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.8.0 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.10.0 // indirect diff --git a/go.sum b/go.sum index 56dfd981..3902fcec 100644 --- a/go.sum +++ b/go.sum @@ -67,6 +67,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0= github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= +github.com/DataDog/datadog-api-client-go/v2 v2.2.0 h1:woWe+XBcYt29g1SJs+zbgwYPfyATb+gxeA2pKqUu02Y= +github.com/DataDog/datadog-api-client-go/v2 v2.2.0/go.mod h1:98b/MtTwSAr/yhTfhCR1oxAqQ/4tMkdrgKH7fYiDA0g= +github.com/DataDog/zstd v1.5.0 h1:+K/VEwIAaPcHiMtQvpLD4lqW7f0Gk3xdYZmI1hD+CXo= +github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= diff --git a/pkg/sink/datadog.go b/pkg/sink/datadog.go new file mode 100644 index 00000000..0c5e259e --- /dev/null +++ b/pkg/sink/datadog.go @@ -0,0 +1,52 @@ +// Copyright (c) 2022 Silverton Data, Inc. +// You may use, distribute, and modify this code under the terms of the AGPLv3 license, a copy of +// which may be found at https://github.com/silverton-io/buz/blob/main/LICENSE + +package sink + +import ( + "context" + + "github.com/google/uuid" + "github.com/silverton-io/buz/pkg/config" + "github.com/silverton-io/buz/pkg/envelope" +) + +type DatadogSink struct { + id *uuid.UUID + name string + deliveryRequired bool +} + +func (s *DatadogSink) Id() *uuid.UUID { + return s.id +} + +func (s *DatadogSink) Name() string { + return s.name +} + +func (s *DatadogSink) Type() string { + return DATADOG +} + +func (s *DatadogSink) DeliveryRequired() bool { + return s.deliveryRequired +} + +func (s *DatadogSink) Initialize(conf config.Sink) error { + id := uuid.New() + s.id, s.name, s.deliveryRequired = &id, conf.Name, conf.DeliveryRequired + return nil +} + +func (s *DatadogSink) BatchPublishValid(ctx context.Context, validEnvelopes []envelope.Envelope) error { + return nil +} + +func (s *DatadogSink) BatchPublishInvalid(ctx context.Context, invalidEnvelopes []envelope.Envelope) error { + return nil +} + +func (s *DatadogSink) Close() { +} diff --git a/pkg/sink/sink.go b/pkg/sink/sink.go index 25fd2d40..d4f5dafb 100644 --- a/pkg/sink/sink.go +++ b/pkg/sink/sink.go @@ -31,6 +31,7 @@ const ( NATS_JETSTREAM string = "nats-jetstream" INDICATIVE string = "indicative" AMPLITUDE string = "amplitude" + DATADOG string = "datadog" ) type Sink interface {