[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: conflict-free replicated data-types



On 4 Jul 2013, at 08:32, Raphaël Proust <raphlalou@xxxxxxxxx> wrote:

> On Wed, Jul 3, 2013 at 5:51 PM, Thomas Gazagnaire <thomas@xxxxxxxxxxxxxx> 
> wrote:
>> Currenlty, the only missing bits is a nice way to exchange distributed 
>> datastructes between actors. I'm using Obj.magic in 
>> https://github.com/samoht/ocaml-crdt/blob/master/test/main.ml, I would be 
>> quite happy to find an other nicer solution (but I have none in mind 
>> currently).
> 
> 
> What about adding a functor layer? I haven't run the code, but I think
> the idea would work. Here is the gist (I can try to run it later and
> send a PR on github if it works).

A functor layer would also let us build faster, non-distributed equivalents
for cases where there is a more consistent connection between actors (e.g.
running within the same process).  But that might require FCM rather than
functors to decide how to do the dispatch.

-anil



> 
> 
> replace ACTOR by:
> 
> module type ACTOR = sig
>       include COMPARABLE
>       val me: t
>       val pack: t -> common
>       val unpack: common -> t
>       type common
> end
> 
> And Make in CRDT.Clock by:
> 
> module MakeMake (C : sig type t end) (A : ACTOR with type common :=
> C.t) = struct
>       ...
> end
> 
> 
> Then the tests can be rewritten as:
> 
> module Common = struct type t = string end
> 
> module Foo = struct
>  include MyString
>  let me = "foo"
>  let pack x = x
>  let unpack x = x
> end
> 
> module Bar = struct
>  include MyString
>  let me = "bar"
>  let pack x = x
>  let unpack x = x
> end
> 
> module ClockTest = struct
> 
>  let name = "clock"
> 
>  module Foo = CRDT.Clock.MakeMake (Common) (Foo)
>  module Bar = CRDT.Clock.MakeMake (Common) (Bar)
> 
>  let run () =
>    let foo = Foo.empty in
>    let bar = Bar.empty in
>    let foo1 = Foo.incr (Foo.incr foo) in
>    let bar1 = Bar.incr bar in
>    let foo2 = Foo.merge foo1 (Foo.unpack (Bar.pack bar1)) in
>    let bar2 = Bar.incr (Bar.incr bar1) in
>    let bar3 = Bar.merge bar2 (Bar.unpack (Foo.pack foo2)) in
>    let foo3 = Foo.merge foo2 (Foo.unpack (Bar.pack bar2)) in
> 
>    test name Foo.contents Foo.to_string int [
>      ("foo1", foo1, 2);
>      ("foo2", foo2, 2);
>      ("foo3", foo3, 2);
>    ];
>    test name Bar.contents Bar.to_string int [
>      ("bar1", bar1, 1);
>      ("bar2", bar2, 3);
>      ("bar3", bar3, 3);
>    ]
> 
> end
> 
> 
> 
> -- 
> ______________
> Raphaël Proust
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.