<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>The Vose Way: Tag Mnesia</title>
    <link>http://www.chuckvose.com/articles/tag/mnesia</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>A Blog about Butter, Cheese, and all things Vosian</description>
    <item>
      <title>Complex commands with Rulang</title>
      <description>&lt;p&gt;Rulang was giving me a lot of trouble with regards to multi-line commands and complex commands in general. After hacking on it for a while I&amp;#8217;ve developed a patch that will allow ruby code such as the following:&lt;/p&gt;


&lt;pre&gt;
require 'rulang'

@mnesia = RulangBridge::Erlang.new("localhost", 9900)

def find
  @mnesia.eval(&amp;lt;&amp;lt;-EOF
    QH = qlc:q([X || X &amp;lt;- mnesia:table(shop)]),
    F = fun() -&amp;gt; qlc:eval(QH) end,
    {atomic, Val} = mnesia:transaction(F),
    Val.
  EOF
  )
end

puts find
&lt;/pre&gt;

	&lt;p&gt;&lt;span class="caps"&gt;PATCH&lt;/span&gt;&lt;/p&gt;


&lt;pre&gt;
diff -u Desktop/rulangbridge/rulang.erl Current Schoolwork/Project/mnesia/rulang_test/rulang.erl
--- Desktop/rulangbridge/rulang.erl     2007-05-17 20:25:50.000000000 -0700
+++ Current Schoolwork/Project/mnesia/rulang_test/rulang.erl    2008-01-03 10:12:05.000000000 -0800
@@ -30,11 +30,15 @@
 handle_connection(Socket) -&amp;gt;
-       Reason = (catch communication(Socket)),
-       gen_tcp:send(Socket, io_lib:format("Error: ~w~n", [Reason])),
+       try communication(Socket)
+  catch
+    error:Reason -&amp;gt;
+         {gen_tcp:send(Socket, io_lib:format("Error: ~p~n", [Reason]))}
+  end,
        ok = gen_tcp:close(Socket).

+% Try to evaluate the code submitted throwing an exception if the evaluation
+% doesn't work. Return the code submitted.
 communication(Socket) -&amp;gt;
        {ok, Binary} = gen_tcp:recv(Socket, 0),
        {ok, Result} = eval(binary_to_list(Binary)),
@@ -43,9 +47,9 @@

 eval(Expression) -&amp;gt;
-       {ok, Scanned, _} = erl_scan:string(Expression),
-       {ok, [Parsed]} = erl_parse:parse_exprs(Scanned),
-       {value, Result, _} = erl_eval:expr(Parsed, []),
+       {done, {ok, Scanned, _}, _} = erl_scan:tokens([], Expression, 0),
+       {ok, Parsed} = erl_parse:parse_exprs(Scanned),
+       {value, Result, _} = erl_eval:exprs(Parsed, []),
        {ok, Result}.

diff -u Desktop/rulangbridge/rulang.rb Current Schoolwork/Project/mnesia/rulang_test/rulang.rb
--- Desktop/rulangbridge/rulang.rb      2007-05-24 10:42:22.000000000 -0700
+++ Current Schoolwork/Project/mnesia/rulang_test/rulang.rb     2008-01-03 10:02:19.000000000 -0800
@@ -79,7 +79,7 @@
                def eval(command)
                        socket = TCPSocket.new(@host, @port)
                        socket.write(command)
-                       socket.gets # ...?
+                       socket.read # ...?
                end
&lt;/pre&gt;</description>
      <pubDate>Thu, 03 Jan 2008 12:17:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:effba11d-9820-471e-8e22-476292ddacae</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2008/01/03/complex-commands-with-rulang</link>
      <category>Ruby</category>
      <category>Mnesia</category>
      <category>Erlang</category>
      <category>Ruby</category>
      <category>Erlang</category>
      <category>Mnesia</category>
      <category>rulang</category>
    </item>
    <item>
      <title>Mnesia + Ruby Announcement</title>
      <description>&lt;p&gt;My goal this year is to release a Ruby port of the Mnesia distributed database and hopefully start the process of moving to a true slice architecture. The port is an interesting project but I think the importance of the slice architecture is paramount.&lt;/p&gt;


	&lt;p&gt;For the last couple of years we&amp;#8217;ve been working on the n-tier model with ruby. It&amp;#8217;s well established and it has been working nicely for us. But the web server industry is starting to move more towards the idea of instances or clouds of ambiguous slices. Amazon is doing it, mongrel is a part of it certainly, Mnesia has always worked this way.&lt;/p&gt;


	&lt;p&gt;My hope is that my port will help us to create an &lt;span class="caps"&gt;EC2&lt;/span&gt; instance that is both the master of it&amp;#8217;s domain and a part of a cloud at the same time. I would like to see an &lt;span class="caps"&gt;EC2&lt;/span&gt; instance that can autoconfigure itself and automatically find its neighbors, which contains a complete Mnesia instance, a couple mongrels, and a proxy/load balancer.&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m not sure if we can do this quite yet but multi-processor theory suggests that it can be done. Whether it&amp;#8217;s advantageous to remove all the bottle-necks and have to deal with the scheduling individually is where we&amp;#8217;ll have to analyze but I&amp;#8217;m confident that we are moving somewhere truly incredible.&lt;/p&gt;


	&lt;p&gt;In the future I hope to be able to drop in a new &lt;span class="caps"&gt;EC2&lt;/span&gt; and just have it completely figure things out for me. No more MySQL master, no more apache proxying. Whether we use my new port or SimpleDB is of no concern to me at all.&lt;/p&gt;</description>
      <pubDate>Sat, 22 Dec 2007 01:17:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a94fd9ce-bee4-4caf-b059-6207e3dc5560</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2007/12/22/mnesia-ruby-announcement</link>
      <category>Ruby</category>
      <category>Mnesia</category>
      <category>Programming</category>
      <category>Erlang</category>
      <category>Mnesia</category>
      <category>Ruby</category>
      <category>Amazon</category>
      <category>EC2</category>
      <category>SimpleDB</category>
      <category>Erlang</category>
      <category>DDBMS</category>
      <category>Distributed</category>
    </item>
    <item>
      <title>Long Bets</title>
      <description>&lt;p&gt;&lt;a href="http://intertwingly.net"&gt;Sam Ruby&lt;/a&gt; occasionally does an article about his long bets and I really respect his ability to predict the future. &lt;a href="http://intertwingly.net/blog/2007/08/12/Long-Bets"&gt;This time&lt;/a&gt; I feel that he was focusing too close and forgot the long part of the &amp;#8216;long bet&amp;#8217;. &lt;span class="caps"&gt;REST&lt;/span&gt; is already important, and there are further developments in edge rails that make it even more important (active resource). MySQL is already a pain for scaling and the plugins are starting to come out but haven&amp;#8217;t really hit the fan yet.&lt;/p&gt;


	&lt;h3&gt;Bet One &amp;#8211; MySQL becomes the exception&lt;/h3&gt;


	&lt;p&gt;First, I think Sam Ruby is dead on about databases. Right now there are only a few things that are a consistent pain for deployment and scaling and databases are the top of the heap. I know there are things like MaxDB for mysql and there are ways to set up ring replication but it&amp;#8217;s hard; something that Ruby&amp;#8217;s community is really good at solving.&lt;/p&gt;


	&lt;p&gt;My first bet is that MySQL dies out for the rails community and something new pops in. It wouldn&amp;#8217;t surprise me if it was &lt;a href="http://www1.erlang.org/documentation/doc-5.0.1/lib/mnesia-3.9.2/doc/index.html"&gt;Mnesia&lt;/a&gt; from &lt;a href="http://www.erlang.se"&gt;Erlang/OTP&lt;/a&gt; or something involving &lt;a href="http://lucene.apache.org/hadoop/"&gt;Hadoop&lt;/a&gt; and &lt;a href="http://wiki.apache.org/lucene-hadoop/Hbase"&gt;HBase&lt;/a&gt;. It would surprise me if &lt;a href="http://www.couchdb.org"&gt;CouchDB&lt;/a&gt; popped onto the scene in a big way but it&amp;#8217;s the sort of thinking that could lead us somewhere interesting. The other option is that someone comes up with a really concrete stack of abstractions that makes it easy to balance mysql requests and writes.&lt;/p&gt;


	&lt;h3&gt;Bet Two &amp;#8211; Rails drops &lt;span class="caps"&gt;REST&lt;/span&gt; completely&lt;/h3&gt;


	&lt;p&gt;Secondly, I think &lt;span class="caps"&gt;REST&lt;/span&gt; is the wrong way to move forward. &lt;span class="caps"&gt;REST&lt;/span&gt; maps very well onto the &lt;span class="caps"&gt;CRUD&lt;/span&gt; principles, but I feel like we very rarely actually use just &lt;span class="caps"&gt;CRUD&lt;/span&gt;. More often than not I want to run custom little things and create crazy associations. And I realize that this is all possible in the &lt;span class="caps"&gt;REST&lt;/span&gt; model, but it makes the controllers obscene sometimes.&lt;/p&gt;


	&lt;p&gt;What we really want is Query Language for the Internet and what better language to build that in than Ruby. I&amp;#8217;ve seen &lt;span class="caps"&gt;DSL&lt;/span&gt;&amp;#8217;s for direct database access and it seems like the routes would be just around the corner if this is where we decide to take it.&lt;/p&gt;


	&lt;p&gt;The question is whether &lt;span class="caps"&gt;DHH&lt;/span&gt; sees the writing on the wall or desperately wants to hang on to &lt;span class="caps"&gt;REST&lt;/span&gt;. Since he&amp;#8217;s put so much effort into the &lt;span class="caps"&gt;REST&lt;/span&gt; idea it seems like he would be loath to drop it, but at the same time he&amp;#8217;s an incredibly mature developer and would hopefully handle a change like this if it ever happened.&lt;/p&gt;


	&lt;h3&gt;Conclusion&lt;/h3&gt;


	&lt;p&gt;All respect to Sam Ruby, I really do respect his predictions over my own. But I think his predictions are too close to us right now. I would like to know what happens after &lt;span class="caps"&gt;REST&lt;/span&gt; and what happens in the database arena.&lt;/p&gt;</description>
      <pubDate>Tue, 11 Sep 2007 23:42:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:048e70f7-20cc-49ba-aac8-3d4bd0f2e433</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2007/09/11/long-bets</link>
      <category>Rails</category>
      <category>MySQL</category>
      <category>Programming</category>
      <category>REST</category>
      <category>MySQL</category>
      <category>Rails</category>
      <category>Future</category>
      <category>Ruby</category>
      <category>Scaling</category>
      <category>Bets</category>
      <category>Hadoop</category>
      <category>HBase</category>
      <category>Mnesia</category>
      <category>Erlang</category>
      <category>CouchDB</category>
    </item>
  </channel>
</rss>

