Skip to content

Commit 7e898b8

Browse files
authored
Log destination file and bucket (#7)
1 parent 1af921f commit 7e898b8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

business/tsextractor/tsextractor.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
)
3535

3636
const importConcurrency = 10
37+
const retryCount = 5
3738

3839
type TsExtractor struct {
3940
iotcl *iot.Client
@@ -117,6 +118,7 @@ func (a *TsExtractor) ExportTSToS3(
117118
defer writer.Delete()
118119

119120
destinationKey := fmt.Sprintf("%s/%s.csv", from.Format("2006-01-02"), from.Format("2006-01-02-15"))
121+
a.logger.Infof("Uploading file %s to bucket %s\n", destinationKey, s3cl.DestinationBucket())
120122
if err := s3cl.WriteFile(ctx, destinationKey, writer.GetFilePath()); err != nil {
121123
return err
122124
}
@@ -151,7 +153,7 @@ func (a *TsExtractor) populateNumericTSDataIntoS3(
151153
var batched *iotclient.ArduinoSeriesBatch
152154
var err error
153155
var retry bool
154-
for i := 0; i < 3; i++ {
156+
for i := 0; i < retryCount; i++ {
155157
batched, retry, err = a.iotcl.GetTimeSeriesByThing(ctx, thingID, from, to, int64(resolution))
156158
if !retry {
157159
break
@@ -253,7 +255,7 @@ func (a *TsExtractor) populateStringTSDataIntoS3(
253255
var batched *iotclient.ArduinoSeriesBatchSampled
254256
var err error
255257
var retry bool
256-
for i := 0; i < 3; i++ {
258+
for i := 0; i < retryCount; i++ {
257259
batched, retry, err = a.iotcl.GetTimeSeriesStringSampling(ctx, stringProperties, from, to, int32(resolution))
258260
if !retry {
259261
break
@@ -313,7 +315,7 @@ func (a *TsExtractor) populateRawTSDataIntoS3(
313315
var batched *iotclient.ArduinoSeriesRawBatch
314316
var err error
315317
var retry bool
316-
for i := 0; i < 3; i++ {
318+
for i := 0; i < retryCount; i++ {
317319
batched, retry, err = a.iotcl.GetRawTimeSeriesByThing(ctx, thingID, from, to)
318320
if !retry {
319321
break

internal/s3/s3.go

+4
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ func (s *S3Client) WriteFile(ctx context.Context, key, filePath string) error {
6363
}
6464
return nil
6565
}
66+
67+
func (s *S3Client) DestinationBucket() string {
68+
return s.bucketName
69+
}

0 commit comments

Comments
 (0)