Skip to content

Commit

Permalink
Rename dynamoCollector to awsCollector
Browse files Browse the repository at this point in the history
  • Loading branch information
jml committed Jun 30, 2016
1 parent 6520f8f commit a87dafd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
30 changes: 15 additions & 15 deletions app/multitenant/dynamo_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -140,7 +140,7 @@ func NewDynamoDBCollector(
}
}

return &dynamoDBCollector{
return &awsCollector{
db: dynamodb.New(session.New(dynamoDBConfig)),
s3: s3Store,
userIDer: userIDer,
Expand All @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions prog/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@ 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,
)
if err != nil {
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)
Expand Down

0 comments on commit a87dafd

Please sign in to comment.