Closed cblp closed 5 years ago
How we should specify one? By new argument to newHandle? Something like:
newHandle :: FilePath -> Maybe Word64 -> IO Handle
newHandle hDataDir hReplicaId = do
...
hReplica <- applicationSpecific <$> fromMaybe getRandomId (getMacAddress <|> hReplicaId)
...
@iupii, yes, good idea.
But it would be better to have a separate function, say, newHandleWithReplica
And there shouldn't be random id in presence of explicit id.
With explicit id
newHandleWithReplicaId :: FilePath -> Maybe Word64 -> IO Handle
newHandleWithReplicaId hDataDir hReplicaId = do
Without
newHandle :: FilePath -> IO Handle
newHandle hDataDir = do
...
hReplica <- applicationSpecific <$> fromMaybe getRandomId getMacAddress
Yes, go for it!
Which random library fits?
PR please
Cool, but rewrite (=<<), (<*>) and nested (<$>) with do-notation to lower barrier.
done in #107
for cases when we cannot guarantee a unique MAC.
And a random id when we even cannot specify one.