DIndex seems to be working, added simple test

This commit is contained in:
Paul Chiusano 2016-09-15 13:03:24 -04:00
parent 2eaacba7e0
commit 328939809c
4 changed files with 16 additions and 6 deletions

View File

@ -121,7 +121,7 @@ process recv = scope "Mux.process" $ do
L.warn logger $ "dropped packet @ " ++ show (Base64.encode destination)
pure True
Just callback -> do
L.warn logger $ "packet delivered @ " ++ show (Base64.encode destination)
L.debug logger $ "packet delivered @ " ++ show (Base64.encode destination)
callback content
pure True

View File

@ -195,9 +195,9 @@ handle crypto allow env lang p r = Mux.debug (show r) >> case r of
Mux.debug $ "runLocal Pure"
liftIO $ eval lang t
runLocal (Send c@(Channel cid) a) = do
Mux.warn $ "runLocal Send " ++ show c ++ " " ++ show a
Mux.debug $ "runLocal Send " ++ show c ++ " " ++ show a
a <- liftIO $ eval lang a
Mux.warn $ "runLocal Send[2] " ++ show c ++ " " ++ show a
Mux.debug $ "runLocal Send[2] " ++ show c ++ " " ++ show a
Mux.process1 (Mux.Packet cid (Put.runPutS (serialize a)))
pure (unit lang)
runLocal (Sleep (Seconds seconds)) = do

11
unison-src/dindex-main.u Normal file
View File

@ -0,0 +1,11 @@
do Remote
root := Remote.spawn;
Remote.transfer root;
ind := DIndex.empty;
nodes := Remote.replicate 10 Remote.spawn;
Remote.traverse (node -> Remote.at' node (DIndex.join ind)) nodes;
DIndex.insert "It's..." "ALIIIVE!!!!" ind;
-- Remote.parallel-traverse DIndex.Timeout (k -> DIndex.insert k k ind) (Vector.range 0 5);
r := DIndex.lookup "It's..." ind;
pure (Debug.watch "result" r);;

View File

@ -35,9 +35,7 @@ DIndex.lookup k ind = do Remote
nind;;)
;
-- todo: use Remote.quorum here
-- Remote.race DIndex.Timeout <| Vector.map localLookup nodes;;
rs := Remote.traverse localLookup nodes;
pure (Vector.at 0 rs |> Optional.bind identity);;
Remote.race DIndex.Timeout <| Vector.map localLookup nodes;;
;
DIndex.insert : ∀ k v . k -> v -> DIndex k v -> Remote Unit;
@ -86,6 +84,7 @@ DIndex.rebalance k ind = do Remote
ov;;)
;;
;
DIndex.leave : ∀ k v . Node -> DIndex k v -> Remote Unit;
DIndex.leave node ind = do Remote
local-ind := Index.lookup node ind;