Skip to content

Commit

Permalink
Commiting some crufty bits of initial persistence attempts for poster…
Browse files Browse the repository at this point in the history
…ity.
  • Loading branch information
lgastako committed Mar 7, 2009
1 parent 790e3fc commit 70f509f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
20 changes: 17 additions & 3 deletions erqnesia.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-module(erqnesia).
-export([create_database/0, start/0]).
-include("queues.hrl").
-export([create_database/0, start/0, enqueue/3]).

%% Run this once to setup the database.
%% TODO: Auto detect database existence and create it automatically.
Expand All @@ -19,8 +20,21 @@ create_schema() ->

create_tables() ->
mnesia:delete_table(queues),
mnesia:create_table(queues,
mnesia:create_table(message,
[
{disc_copies, [node()]},
{type, ordered_set}
{type, ordered_set},
{attributes, record_info(fields, message)}
]).

enqueue(QueueName, Data, Flags) ->
mnesia:transaction(fun() ->
mnesia:write(#message{queue_name=QueueName,
data=Data,
flags=Flags})
end).

%% dequeue(QueueName) ->
%% mnesia:transaction(fun() ->
%% Key = mnesia:first(messages),

26 changes: 26 additions & 0 deletions journal.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-module(journal).
-export(...).

start_journal_for_queue_path(QueuePath) ->
spawn(fun() -> manage_journal(QueuePath) end).

manage_journal(QueuePath) ->
receive
%% {cmd, open} -> do_open(QueuePath);
%% {cmd, erase} -> do_erase(QueuePath);
%% {cmd, roll} -> do_roll(QueuePath);
%% {cmd, close} -> do_close(QueuePath);
%% {cmd, add} -> do_add(QueuePath);
%% {cmd, add_with_xid} -> do_add_with_xid(QueuePath);
%% remove
%% remove_tentative
%% unremove
%% confirm ->

erase(Journal) ->
close it and delete it.

write_items(Journal, Items) ->
...


1 change: 1 addition & 0 deletions queues.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-record(message, {queue_name, data, flags}).

0 comments on commit 70f509f

Please sign in to comment.