ff-notes / ron

Haskell implementation of RON and RON-RDT
BSD 3-Clause "New" or "Revised" License
65 stars 9 forks source link

Add ability to runStorage with specific identifier #82

Closed cblp closed 5 years ago

cblp commented 5 years ago

for cases when we cannot guarantee a unique MAC.

And a random id when we even cannot specify one.

iupii commented 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)
...
cblp commented 5 years ago

@iupii, yes, good idea.

But it would be better to have a separate function, say, newHandleWithReplica

cblp commented 5 years ago

And there shouldn't be random id in presence of explicit id.

iupii commented 5 years ago

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
cblp commented 5 years ago

Yes, go for it!

iupii commented 5 years ago

Which random library fits?

iupii commented 5 years ago

With tf-random https://github.com/iupii/ron/commit/1c467faf5878d367ae66f5e3832f4d660f78f119

cblp commented 5 years ago

PR please

cblp commented 5 years ago

Cool, but rewrite (=<<), (<*>) and nested (<$>) with do-notation to lower barrier.

cblp commented 5 years ago

done in #107