diff --git a/app/multitenant/dynamo_collector.go b/app/multitenant/aws_collector.go similarity index 93% rename from app/multitenant/dynamo_collector.go rename to app/multitenant/aws_collector.go index 82db7ef56..ad0e36e2d 100644 --- a/app/multitenant/dynamo_collector.go +++ b/app/multitenant/aws_collector.go @@ -83,8 +83,8 @@ func init() { prometheus.MustRegister(natsRequests) } -// DynamoDBCollector is a Collector which can also CreateTables -type DynamoDBCollector interface { +// AWSCollector is a Collector which can also CreateTables +type AWSCollector interface { app.Collector CreateTables() error } @@ -94,7 +94,7 @@ type ReportStore interface { FetchReports([]string) (map[string]report.Report, []string, error) } -type dynamoDBCollector struct { +type awsCollector struct { userIDer UserIDer db *dynamodb.DynamoDB s3 *S3Store @@ -122,15 +122,15 @@ type watchKey struct { c chan struct{} } -// NewDynamoDBCollector the reaper of souls +// NewAWSCollector the elastic reaper of souls // https://github.com/aws/aws-sdk-go/wiki/common-examples -func NewDynamoDBCollector( +func NewAWSCollector( userIDer UserIDer, dynamoDBConfig *aws.Config, tableName string, s3Store *S3Store, natsHost string, memcacheClient *MemcacheClient, -) (DynamoDBCollector, error) { +) (AWSCollector, error) { var nc *nats.Conn if natsHost != "" { var err error @@ -140,7 +140,7 @@ func NewDynamoDBCollector( } } - return &dynamoDBCollector{ + return &awsCollector{ db: dynamodb.New(session.New(dynamoDBConfig)), s3: s3Store, userIDer: userIDer, @@ -153,8 +153,8 @@ func NewDynamoDBCollector( }, nil } -// CreateDynamoDBTables creates the required tables in dynamodb -func (c *dynamoDBCollector) CreateTables() error { +// CreateTables creates the required tables in dynamodb +func (c *awsCollector) CreateTables() error { // see if tableName exists resp, err := c.db.ListTables(&dynamodb.ListTablesInput{ Limit: aws.Int64(10), @@ -206,7 +206,7 @@ func (c *dynamoDBCollector) CreateTables() error { } // getReportKeys gets the s3 keys for reports in this range -func (c *dynamoDBCollector) getReportKeys(userid string, row int64, start, end time.Time) ([]string, error) { +func (c *awsCollector) getReportKeys(userid string, row int64, start, end time.Time) ([]string, error) { rowKey := fmt.Sprintf("%s-%s", userid, strconv.FormatInt(row, 10)) var resp *dynamodb.QueryOutput err := timeRequest("Query", dynamoRequestDuration, func() error { @@ -254,7 +254,7 @@ func (c *dynamoDBCollector) getReportKeys(userid string, row int64, start, end t return result, nil } -func (c *dynamoDBCollector) getReports(reportKeys []string) ([]report.Report, error) { +func (c *awsCollector) getReports(reportKeys []string) ([]report.Report, error) { missing := reportKeys stores := []ReportStore{c.inProcess} @@ -287,7 +287,7 @@ func (c *dynamoDBCollector) getReports(reportKeys []string) ([]report.Report, er return reports, nil } -func (c *dynamoDBCollector) Report(ctx context.Context) (report.Report, error) { +func (c *awsCollector) Report(ctx context.Context) (report.Report, error) { var ( now = time.Now() start = now.Add(-15 * time.Second) @@ -327,7 +327,7 @@ func (c *dynamoDBCollector) Report(ctx context.Context) (report.Report, error) { return c.merger.Merge(reports), nil } -func (c *dynamoDBCollector) Add(ctx context.Context, rep report.Report) error { +func (c *awsCollector) Add(ctx context.Context, rep report.Report) error { userid, err := c.userIDer(ctx) if err != nil { return err @@ -406,7 +406,7 @@ func (c *dynamoDBCollector) Add(ctx context.Context, rep report.Report) error { return nil } -func (c *dynamoDBCollector) WaitOn(ctx context.Context, waiter chan struct{}) { +func (c *awsCollector) WaitOn(ctx context.Context, waiter chan struct{}) { userid, err := c.userIDer(ctx) if err != nil { log.Errorf("Error getting user id in WaitOn: %v", err) @@ -447,7 +447,7 @@ func (c *dynamoDBCollector) WaitOn(ctx context.Context, waiter chan struct{}) { }() } -func (c *dynamoDBCollector) UnWait(ctx context.Context, waiter chan struct{}) { +func (c *awsCollector) UnWait(ctx context.Context, waiter chan struct{}) { userid, err := c.userIDer(ctx) if err != nil { log.Errorf("Error getting user id in WaitOn: %v", err) diff --git a/prog/app.go b/prog/app.go index e898eaccf..1ca9cfb55 100644 --- a/prog/app.go +++ b/prog/app.go @@ -125,7 +125,7 @@ func collectorFactory(userIDer multitenant.UserIDer, collectorURL, s3URL, natsHo return nil, err } } - dynamoCollector, err := multitenant.NewDynamoDBCollector( + awsCollector, err := multitenant.NewAWSCollector( userIDer, dynamoDBConfig, tableName, &s3Store, natsHostname, memcacheClient, ) @@ -133,11 +133,11 @@ func collectorFactory(userIDer multitenant.UserIDer, collectorURL, s3URL, natsHo return nil, err } if createTables { - if err := dynamoCollector.CreateTables(); err != nil { + if err := awsCollector.CreateTables(); err != nil { return nil, err } } - return dynamoCollector, nil + return awsCollector, nil } return nil, fmt.Errorf("Invalid collector '%s'", collectorURL)