obsidiansystems / rhyolite

BSD 3-Clause "New" or "Revised" License
26 stars 17 forks source link

Purify function argument to decrypt token in handleAuthenticatedQuery #208

Closed cgibbard closed 1 year ago

cgibbard commented 1 year ago

We recently had a performance issue where a database query was being done in the function passed to handleAuthenticatedQuery that reads user tokens. The function given there runs for every connected user on every database notification, and so needs to be faster than doing an extra separate database query for each user. In order to prevent this type of mistake from reoccurring in the future, since the actual function we essentially always want to use is a partial application of readSignedWithKey which is a pure function, I'm making that function argument pure.