add cloud sync data in cache
This commit is contained in:
+12
-3
@@ -3818,9 +3818,10 @@ func handleCloudJob(job shuffle.CloudSyncJob) error {
|
|||||||
// Handles jobs from remote (cloud)
|
// Handles jobs from remote (cloud)
|
||||||
func remoteOrgJobController(org shuffle.Org, body []byte) error {
|
func remoteOrgJobController(org shuffle.Org, body []byte) error {
|
||||||
type retStruct struct {
|
type retStruct struct {
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
Reason string `json:"reason"`
|
Reason string `json:"reason"`
|
||||||
Jobs []shuffle.CloudSyncJob `json:"jobs"`
|
Jobs []shuffle.CloudSyncJob `json:"jobs"`
|
||||||
|
SyncFeatures shuffle.SyncFeatures `json:"sync_features"`
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData := retStruct{}
|
responseData := retStruct{}
|
||||||
@@ -3887,6 +3888,14 @@ func remoteOrgJobController(org shuffle.Org, body []byte) error {
|
|||||||
log.Printf("Got job with reason %s and %d job(s)", responseData.Reason, len(responseData.Jobs))
|
log.Printf("Got job with reason %s and %d job(s)", responseData.Reason, len(responseData.Jobs))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cacheKey := fmt.Sprintf("org_sync_features_%s", org.Id)
|
||||||
|
featuresBytes, err := json.Marshal(responseData.SyncFeatures)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("[ERROR] Failed to marshal SyncFeatures for cache: %s", err)
|
||||||
|
} else {
|
||||||
|
shuffle.SetCache(ctx, cacheKey, featuresBytes, 30)
|
||||||
|
}
|
||||||
|
|
||||||
for _, job := range responseData.Jobs {
|
for _, job := range responseData.Jobs {
|
||||||
err = handleCloudJob(job)
|
err = handleCloudJob(job)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user