Skip to content

Commit

Permalink
Merge pull request #14 from Clever/DEIP-973
Browse files Browse the repository at this point in the history
DEIP-973
  • Loading branch information
a-le-jan-dro authored Oct 28, 2022
2 parents caa5a42 + 3a9e5c0 commit b3096cf
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 98 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Defining checks in analytics-latency-config-service can be accomplished by addin
]
```

`analytics-latency-config-service` then reads from this config to surface latency info to other workers/services. `schema` + `table` identifies the table, and `latency.timestamp_column` identifies the time a row enters Redshift. `latency.thresholds` configures the different tiers of latency thresholds maximum amount of latency acceptable for the table's data in [Go time format](https://golang.org/pkg/time/#ParseDuration).
`analytics-latency-config-service` then reads from this config to surface latency info to other workers/services. `schema` + `table` identifies the table, and `latency.timestamp_column` identifies the time a row enters the source database. `latency.thresholds` configures the different tiers of latency thresholds maximum amount of latency acceptable for the table's data in [Go time format](https://golang.org/pkg/time/#ParseDuration).

For tables that are not explicitly declared in the config, `default_threshold` and `default_timestamp_column` will be used as substitutes for the above values.

Expand Down
18 changes: 1 addition & 17 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,7 @@ import (
)

var (
// We have two redshift databases:
// One that holds all the data and views (prod)
// And one that holds timeline (fast-prod)
// RedshiftProd* are for the former
RedshiftProdHost string
RedshiftProdPort string
RedshiftProdDatabase string
RedshiftProdUsername string
RedshiftProdPassword string

// RedshiftFast* are for the latter
// RedshiftFast* holds timeline (fast-prod)
RedshiftFastHost string
RedshiftFastPort string
RedshiftFastDatabase string
Expand Down Expand Up @@ -79,12 +69,6 @@ func Init() {

// InitDBs reads environment DB variables and initializes the config.
func InitDBs() {
RedshiftProdHost = requiredEnv("REDSHIFT_PROD_HOST")
RedshiftProdPort = requiredEnv("REDSHIFT_PROD_PORT")
RedshiftProdDatabase = requiredEnv("REDSHIFT_PROD_DATABASE")
RedshiftProdUsername = requiredEnv("REDSHIFT_PROD_USER")
RedshiftProdPassword = requiredEnv("REDSHIFT_PROD_PASSWORD")

RedshiftFastHost = requiredEnv("REDSHIFT_FAST_HOST")
RedshiftFastPort = requiredEnv("REDSHIFT_FAST_PORT")
RedshiftFastDatabase = requiredEnv("REDSHIFT_FAST_DATABASE")
Expand Down
1 change: 0 additions & 1 deletion config/config_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

func validateLatencyConfig(configs models.AnalyticsLatencyConfigs) {
dbs := []models.AnalyticsDatabase{
models.AnalyticsDatabaseRedshiftProd,
models.AnalyticsDatabaseRedshiftFast,
models.AnalyticsDatabaseRdsInternal,
models.AnalyticsDatabaseRdsExternal,
Expand Down
9 changes: 0 additions & 9 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

// Controller implements server.Controller
type Controller struct {
redshiftProdConnection db.DBClient
redshiftFastConnection db.DBClient
rdsExternalConnection db.DBClient
rdsInternalConnection db.DBClient
Expand All @@ -24,8 +23,6 @@ type Controller struct {

func (c *Controller) getDatabaseConnection(database models.AnalyticsDatabase) (db.DBClient, error) {
switch database {
case models.AnalyticsDatabaseRedshiftProd:
return c.redshiftProdConnection, nil
case models.AnalyticsDatabaseRedshiftFast:
return c.redshiftFastConnection, nil
case models.AnalyticsDatabaseRdsInternal:
Expand All @@ -41,11 +38,6 @@ func (c *Controller) getDatabaseConnection(database models.AnalyticsDatabase) (d

func New() (*Controller, error) {
var mErrors *multierror.Error
redshiftProdConnection, err := db.NewRedshiftProdClient()
if err != nil {
mErrors = multierror.Append(mErrors, fmt.Errorf("redshift-prod-failed-init: %s", err.Error()))
}

redshiftFastConnection, err := db.NewRedshiftFastClient()
if err != nil {
mErrors = multierror.Append(mErrors, fmt.Errorf("redshift-fast-failed-init: %s", err.Error()))
Expand Down Expand Up @@ -73,7 +65,6 @@ func New() (*Controller, error) {
}

return &Controller{
redshiftProdConnection: redshiftProdConnection,
redshiftFastConnection: redshiftFastConnection,
rdsExternalConnection: rdsExternalConnection,
rdsInternalConnection: rdsInternalConnection,
Expand Down
13 changes: 0 additions & 13 deletions db/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@ func NewPostgresClient(info PostgresCredentials, clusterName string) (*Postgres,
return &Postgres{session, clusterName}, nil
}

// NewRedshiftProdClient initializes a client to fresh prod
func NewRedshiftProdClient() (*Postgres, error) {
info := PostgresCredentials{
Host: config.RedshiftProdHost,
Port: config.RedshiftProdPort,
Username: config.RedshiftProdUsername,
Password: config.RedshiftProdPassword,
Database: config.RedshiftProdDatabase,
}

return NewPostgresClient(info, "redshift-prod")
}

// NewRedshiftFastClient initializes a client to fast prod
func NewRedshiftFastClient() (*Postgres, error) {
info := PostgresCredentials{
Expand Down
2 changes: 1 addition & 1 deletion gen-go/client/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions gen-go/models/analytics_database.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 0 additions & 36 deletions gen-go/models/analytics_latency_configs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen-js/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen-js/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gen-js/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ func GetThresholdTierErrorValue(tier models.ThresholdTier) (int, error) {
// GetDatabaseConfig returns the database-specific config
func GetDatabaseConfig(configs models.AnalyticsLatencyConfigs, database models.AnalyticsDatabase) ([]*models.SchemaConfig, error) {
switch database {
case models.AnalyticsDatabaseRedshiftProd:
return configs.RedshiftProd, nil
case models.AnalyticsDatabaseRedshiftFast:
return configs.RedshiftFast, nil
case models.AnalyticsDatabaseRdsInternal:
Expand Down
5 changes: 0 additions & 5 deletions launch/analytics-latency-config-service.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
env:
- TRACING_ACCESS_TOKEN
- TRACING_INGEST_URL
- REDSHIFT_PROD_DATABASE
- REDSHIFT_PROD_USER
- REDSHIFT_PROD_PASSWORD
- REDSHIFT_PROD_HOST
- REDSHIFT_PROD_PORT
- REDSHIFT_FAST_DATABASE
- REDSHIFT_FAST_USER
- REDSHIFT_FAST_PASSWORD
Expand Down
8 changes: 1 addition & 7 deletions swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
description: Service for surfacing latency config settings for the analytics pipeline.
# when changing the version here, make sure to run
# `make generate` to generate clients and server
version: 0.3.0
version: 0.4.0
x-npm-package: '@clever/analytics-latency-config-service'
schemes:
- http
Expand Down Expand Up @@ -185,16 +185,11 @@ definitions:

AnalyticsLatencyConfigs:
required:
- redshiftProd
- redshiftFast
- rdsInternal
- rdsExternal
- snowflake
properties:
redshiftProd:
type: array
items:
$ref: "#/definitions/SchemaConfig"
redshiftFast:
type: array
items:
Expand All @@ -216,7 +211,6 @@ definitions:
type: string
description: Analytics databases, in config
enum:
- "RedshiftProd"
- "RedshiftFast"
- "RdsInternal"
- "RdsExternal"
Expand Down

0 comments on commit b3096cf

Please sign in to comment.