There is a problem with the getKey and getKeyEnv from clientsession: they both silently default to generating a new key when one is missing.
Can we change these functions (actually add new ones) that essentially return an Either? Left would be a default, and in that case a warning can be logged for the user.
I would suggest as new function names keyFromFile and keyFromEnv.
However, this points to the fact that some kind of generic key generator is needed. Also, Either may not be descriptive enough.
data KeyGenerator = KeyGenerator { gatherKey :: IO ByteString, writeKey :: ByteString -> IO () }
data KeyInit = KeyGenerated Text Key -- ^ no key was found, generated and recorded a new one
| KeyFound Key -- ^ found the existing key
keyFrom :: KeyGenerator -> KeyInit
keyFromDef :: KeyGenerator -> Key
There is a problem with the getKey and getKeyEnv from clientsession: they both silently default to generating a new key when one is missing.
Can we change these functions (actually add new ones) that essentially return an Either? Left would be a default, and in that case a warning can be logged for the user.
I would suggest as new function names
keyFromFileandkeyFromEnv.However, this points to the fact that some kind of generic key generator is needed. Also, Either may not be descriptive enough.