Skip to content
Permalink
Browse files

refactor(redis): use the extracted redis implementation from fxa-shared

  • Loading branch information...
philbooth committed Mar 8, 2019
1 parent 7fe15bf commit 87f1bb027c0bed600a8f663d751c4c38d140dbd8
@@ -0,0 +1,41 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

'use strict'

const error = require('./error')

module.exports = (config, log) => {
const redis = require('fxa-shared/redis')(config, log)
if (! redis) {
return
}

return Object.entries(redis).reduce((object, [ key, value ]) => {
if (typeof value === 'function') {
object[key] = async (...args) => {
try {
return await value(...args)
} catch (err) {
if (err.message === 'redis.watch.conflict') {
// If you see this line in a stack trace in Sentry
// it's nothing to worry about, just a sign that our
// protection against concurrent updates is working
// correctly. fxa-shared is responsible for logging.
throw error.unexpectedError()
}

// If you see this line in a stack trace in Sentry
// it means something unexpected has really occurred.
// fxa-shared is responsible for logging.
throw error.unexpectedError()
}
}
} else {
object[key] = value
}

return object
}, {})
}

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 87f1bb0

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.