Skip to content

Commit

Permalink
Replace godspeed with datadog-go #minor
Browse files Browse the repository at this point in the history
  • Loading branch information
jessekempf-vsco committed Mar 14, 2024
1 parent 0c6d225 commit e50ca70
Show file tree
Hide file tree
Showing 13 changed files with 156 additions and 488 deletions.
52 changes: 6 additions & 46 deletions cli/api/client.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package api

import (
"encoding/json"
"errors"
"fmt"
"os"
"strings"

"encoding/json"

"time"

"github.com/theckman/godspeed"
"github.com/DataDog/datadog-go/v5/statsd"
"github.com/vsco/dcdr/cli/api/ioutil2"
"github.com/vsco/dcdr/cli/api/stores"
"github.com/vsco/dcdr/cli/printer"
Expand Down Expand Up @@ -46,11 +44,11 @@ type ClientIFace interface {
type Client struct {
Store stores.IFace
Repo repo.IFace
Stats *godspeed.Godspeed
Stats statsd.ClientInterface
config *config.Config
}

func New(st stores.IFace, rp repo.IFace, cfg *config.Config, stats *godspeed.Godspeed) (c *Client) {
func New(st stores.IFace, rp repo.IFace, cfg *config.Config, stats statsd.ClientInterface) (c *Client) {
c = &Client{
Store: st,
Repo: rp,
Expand Down Expand Up @@ -143,15 +141,7 @@ func (c *Client) Set(ft *models.Feature) error {
return err
}

err = c.Store.Set(ft.ScopedKey(), bts)

if err != nil {
return err
}

err = c.SendStatEvent(ft, false)

return nil
return c.Store.Set(ft.ScopedKey(), bts)
}

func (c *Client) Get(key string, v interface{}) error {
Expand Down Expand Up @@ -196,15 +186,7 @@ func (c *Client) Delete(key string, scope string) error {
return KeyNotFoundError(key)
}

err = c.Store.Delete(key)

if err != nil {
return err
}

err = c.SendStatEvent(existing, true)

return err
return c.Store.Delete(key)
}

func (c *Client) Commit(ft *models.Feature, deleted bool) error {
Expand Down Expand Up @@ -348,28 +330,6 @@ func (c *Client) WriteOutputFile(kvb stores.KVBytes) {
printer.Logf("wrote changes to: %s", c.config.Watcher.OutputPath)
}

func (c *Client) SendStatEvent(f *models.Feature, delete bool) error {
if c.Stats == nil {
return nil
}

var text string
title := "Decider Change"

if delete {
text = fmt.Sprintf("deleted %s", f.ScopedKey())
} else {
text = fmt.Sprintf("set %s: %v", f.ScopedKey(), f.Value)
}

optionals := make(map[string]string)
optionals["alert_type"] = "info"
optionals["source_type_name"] = "dcdr"
tags := []string{"source_type:dcdr"}

return c.Stats.Event(title, text, optionals, tags)
}

// KVsToFeatures helper for unmarshalling `KVBytes` to a `FeatureMap`
func (c *Client) KVsToFeatureMap(kvb stores.KVBytes) (*models.FeatureMap, error) {
fm := models.EmptyFeatureMap()
Expand Down
4 changes: 2 additions & 2 deletions cli/api/resolver/storage_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import (

"github.com/vsco/dcdr/cli/api/stores"
"github.com/vsco/dcdr/cli/api/stores/consul"
"github.com/vsco/dcdr/cli/api/stores/etcd"
"github.com/vsco/dcdr/cli/api/stores/redis"
"github.com/vsco/dcdr/config"
)

func LoadStore(cfg *config.Config) stores.IFace {
switch cfg.Storage {
case "etcd":
return etcd.New(cfg)
log.Fatal("etcd is no longer supported")
return nil
case "redis":
r, err := redis.New(cfg)

Expand Down
198 changes: 0 additions & 198 deletions cli/api/stores/etcd/etcd_store.go

This file was deleted.

Loading

0 comments on commit e50ca70

Please sign in to comment.