Add kv queue to google drive / google cloud storage sync handlers

Change-Id: I978ae42dbc6ce2840071cbadaf9351498a23415f
This commit is contained in:
Philip Snowberger 2014-03-09 01:11:57 -08:00 committed by Brad Fitzpatrick
parent 3d7c093ac8
commit 1ba212d707
2 changed files with 22 additions and 4 deletions

View File

@ -266,7 +266,7 @@ func addS3Config(params *configPrefixesParams, prefixes jsonconfig.Obj, s3 strin
return nil return nil
} }
func addGoogleDriveConfig(prefixes jsonconfig.Obj, highCfg string) error { func addGoogleDriveConfig(params *configPrefixesParams, prefixes jsonconfig.Obj, highCfg string) error {
f := strings.SplitN(highCfg, ":", 4) f := strings.SplitN(highCfg, ":", 4)
if len(f) != 4 { if len(f) != 4 {
return errors.New(`genconfig: expected "googledrive" field to be of form "client_id:client_secret:refresh_token:parent_id"`) return errors.New(`genconfig: expected "googledrive" field to be of form "client_id:client_secret:refresh_token:parent_id"`)
@ -309,6 +309,11 @@ func addGoogleDriveConfig(prefixes jsonconfig.Obj, highCfg string) error {
"handlerArgs": map[string]interface{}{ "handlerArgs": map[string]interface{}{
"from": "/bs/", "from": "/bs/",
"to": prefix, "to": prefix,
"queue": map[string]interface{}{
"type": "kv",
"file": filepath.Join(params.blobPath,
"sync-to-googledrive-queue.kv"),
},
}, },
} }
} }
@ -316,7 +321,7 @@ func addGoogleDriveConfig(prefixes jsonconfig.Obj, highCfg string) error {
return nil return nil
} }
func addGoogleCloudStorageConfig(prefixes jsonconfig.Obj, highCfg string) error { func addGoogleCloudStorageConfig(params *configPrefixesParams, prefixes jsonconfig.Obj, highCfg string) error {
f := strings.SplitN(highCfg, ":", 4) f := strings.SplitN(highCfg, ":", 4)
if len(f) != 4 { if len(f) != 4 {
return errors.New(`genconfig: expected "googlecloudstorage" field to be of form "client_id:client_secret:refresh_token:bucket"`) return errors.New(`genconfig: expected "googlecloudstorage" field to be of form "client_id:client_secret:refresh_token:bucket"`)
@ -365,6 +370,11 @@ func addGoogleCloudStorageConfig(prefixes jsonconfig.Obj, highCfg string) error
"handlerArgs": map[string]interface{}{ "handlerArgs": map[string]interface{}{
"from": "/bs/", "from": "/bs/",
"to": gsPrefix, "to": gsPrefix,
"queue": map[string]interface{}{
"type": "kv",
"file": filepath.Join(params.blobPath,
"sync-to-googlecloud-queue.kv"),
},
}, },
} }
} }
@ -686,12 +696,12 @@ func genLowLevelConfig(conf *serverconfig.Config) (lowLevelConf *Config, err err
} }
} }
if conf.GoogleDrive != "" { if conf.GoogleDrive != "" {
if err := addGoogleDriveConfig(prefixes, conf.GoogleDrive); err != nil { if err := addGoogleDriveConfig(prefixesParams, prefixes, conf.GoogleDrive); err != nil {
return nil, err return nil, err
} }
} }
if conf.GoogleCloudStorage != "" { if conf.GoogleCloudStorage != "" {
if err := addGoogleCloudStorageConfig(prefixes, conf.GoogleCloudStorage); err != nil { if err := addGoogleCloudStorageConfig(prefixesParams, prefixes, conf.GoogleCloudStorage); err != nil {
return nil, err return nil, err
} }
} }

View File

@ -114,6 +114,10 @@
"handler": "sync", "handler": "sync",
"handlerArgs": { "handlerArgs": {
"from": "/bs/", "from": "/bs/",
"queue": {
"file": "/tmp/blobs/sync-to-googlecloud-queue.kv",
"type": "kv"
},
"to": "/sto-googlecloudstorage/" "to": "/sto-googlecloudstorage/"
} }
}, },
@ -121,6 +125,10 @@
"handler": "sync", "handler": "sync",
"handlerArgs": { "handlerArgs": {
"from": "/bs/", "from": "/bs/",
"queue": {
"file": "/tmp/blobs/sync-to-googledrive-queue.kv",
"type": "kv"
},
"to": "/sto-googledrive/" "to": "/sto-googledrive/"
} }
}, },