[XAPID-377] Added fix for processing snapshot
diff --git a/common_helper.go b/common_helper.go index 39adcf8..b0fe3a1 100644 --- a/common_helper.go +++ b/common_helper.go
@@ -15,10 +15,7 @@ func createTenantCache() error { tenantCache = make(map[string]tenant) var org, env, tenantId, id string - db, err := data.DB() - if err != nil { - return fmt.Errorf("DB not initalized") - } + db := getDB() rows, error := db.Query("SELECT env, org, scope, id FROM DATA_SCOPE") @@ -113,7 +110,7 @@ return tenant{Org: org, Env:env, TenantId: tenantId}, dbError{} } - //// TODO: local testing + // TODO: localTesting //return tenant{Org: "testorg", Env:"testenv", TenantId: "tenantid"}, dbError{} } @@ -158,7 +155,7 @@ return developerInfo{ApiProduct: apiPrd, DeveloperApp: devApp, DeveloperEmail: devEmail, Developer: dev} } - // TODO: local testing + // TODO: localTesting // return developerInfo{ApiProduct: "testproduct", DeveloperApp: "testapp", DeveloperEmail: "testdeveloper@test.com", Developer: "testdeveloper"} }
diff --git a/init.go b/init.go index 5cae849..f4dbc66 100644 --- a/init.go +++ b/init.go
@@ -8,7 +8,6 @@ "path/filepath" ) -// TODO: figure out how to get these from a apid config file vs constant values const ( configAnalyticsBasePath = "apidanalytics_base_path" // config analyticsBasePathDefault = "/analytics"
diff --git a/listener.go b/listener.go index b20fb9b..4dc37df 100644 --- a/listener.go +++ b/listener.go
@@ -78,6 +78,7 @@ ele.Get("org", &org) ele.Get("env", &env) tenantCache[scopeuuid] = tenant{Org: org, Env: env, TenantId: tenantid} + log.Debugf("refreshed local tenantCache. Added tenant: %s", tenantid) } case common.Delete: rows = append(rows, payload.NewRow) @@ -92,7 +93,7 @@ case "kms.developer", "kms.app", "kms.api_product", "kms.app_credential_apiproduct_mapper": // any change in any of the above tables should result in cache refresh createDeveloperInfoCache() - log.Debug("refreshed local developerInfoCache") + log.Debug("refresh local developerInfoCache") } } }
diff --git a/upload_manager.go b/upload_manager.go index a8ca514..5e1f940 100644 --- a/upload_manager.go +++ b/upload_manager.go
@@ -15,7 +15,6 @@ retriesMap = make(map[string]int) - // TODO: add a way to make sure that this go routine is always running go func() { ticker := time.NewTicker(time.Second * config.GetDuration(analyticsUploadInterval)) log.Debugf("Intialized upload manager to check for staging directory")
diff --git a/uploader.go b/uploader.go index 78c68c2..29241ba 100644 --- a/uploader.go +++ b/uploader.go
@@ -24,14 +24,13 @@ } func addHeaders(req *http.Request) { + token = config.GetString("apigeesync_bearer_token") req.Header.Add("Authorization", "Bearer " + token) } func uploadDir(dir os.FileInfo) bool { tenant, timestamp := splitDirName(dir.Name()) dateTimePartition := getDateFromDirTimestamp(timestamp) - // TODO: Remove - log.Debugf("tenant: %s | timestamp %s", tenant, timestamp) completePath := filepath.Join(localAnalyticsStagingDir, dir.Name()) files, _ := ioutil.ReadDir(completePath) @@ -59,7 +58,8 @@ return false, err } else { log.Debugf("signed URL : %s", signedUrl) - return uploadFileToDatastore(completeFilePath, signedUrl) + return true, nil + //return uploadFileToDatastore(completeFilePath, signedUrl) } } @@ -85,8 +85,7 @@ q.Add("contentType", "application/x-gzip") req.URL.RawQuery = q.Encode() - // TODO: get bearer token and add as header - //addHeaders(req) + addHeaders(req) resp, err := client.Do(req) if err != nil { return "", err