Permalink
Browse files

Add Medici code to the repository, update Makefiles.

Still need to work out these dependencies.
  • Loading branch information...
1 parent d39a1b7 commit 788d56f8c384b03ea25d3f9832465216b7c2f4b6 Evan Miller committed Sep 28, 2009
@@ -2,4 +2,4 @@
-compile(export_all).
world(Req) ->
- {ok, [{world, "World"}]}.
+ {ok, [{greeting, greeting:new(id, "Hello, World!")}]}.
View
@@ -1,5 +1,3 @@
{"src/*", [debug_info, {outdir, "ebin"}]}.
-{"src/drivers/*", [debug_info, {outdir, "ebin"}]}.
{"deps/erlydtl/src/erlydtl/*", [debug_info, {outdir, "deps/erlydtl/ebin"}]}.
-{"deps/medici/src/*", [debug_info, {outdir, "deps/medici/ebin"}]}.
{"deps/mochiweb/src/*", [debug_info, {outdir, "deps/mochiweb/ebin"}]}.
View
@@ -1,19 +1,27 @@
ERL=erl
ERLC=erlc
+DRIVER_APP=medici.app
DB_APP=boss_db.app
APP=boss.app
APPLICATION=boss
-DEPS = erlydtl mochiweb medici
+DEPS = erlydtl mochiweb
-all: ebin/$(APP) ebin/$(DB_APP)
+all: ebin/$(APP) ebin/$(DB_APP) ebin/$(DRIVER_APP) log
$(ERL) -make
# -for d in $(DEPS); do (cd deps/$$d; $(MAKE) all) done
+log:
+ -mkdir -p log
+
+ebin/$(APP): src/$(APP)
+ -mkdir -p ebin
+ cp $< $@
+
ebin/$(DB_APP): src/$(DB_APP)
-mkdir -p ebin
cp $< $@
-ebin/$(APP): src/$(APP)
+ebin/$(DRIVER_APP): src/$(DRIVER_APP)
-mkdir -p ebin
cp $< $@
@@ -23,5 +31,7 @@ clean:
rm -fv ebin/$(APP)
edoc:
+ -mkdir -p doc
+ cp src/overview.edoc doc/
$(ERL) -noshell -eval "edoc:application($(APPLICATION), \".\", [])" \
-s init stop
View
@@ -1,12 +1,26 @@
= GETTING STARTED WITH CHICAGO BOSS =
-Build with "make"
+Erlang dependencies:
+* Erlang R13 -
+ http://www.erlang.org/download.html
+* ErlyDTL -
+ svn checkout http://erlydtl.googlecode.com/svn/trunk/ deps/erlydtl
+* MochiWeb -
+ svn checkout http://mochiweb.googlecode.com/svn/trunk/ deps/mochiweb
-You will need:
-* Tokyo Tyrant running a Table database.
-* Erlang R13. (Check your version with erlang:system_info(otp_release) ).
+Build with "make".
-Open up boss.config to set your database info and the port you want to run the server on. When you're ready to rock and roll, run ./start-dev.sh in this directory. There will be a lot of PROGRESS REPORTs which look scary but hopefully everything is running smoothly. With this console you can interact directly with the running server. Next, point your browser to:
+Other dependencies:
+* Tokyo Tyrant -
+ http://1978th.net/tokyotyrant/
+
+ You need Tyrant up and running with a Table database.
+
+Open up boss.config to set your database info and the port you want to run the
+server on. When you're ready to rock and roll, run ./start-dev.sh in this
+directory. There will be a lot of PROGRESS REPORTs which look scary but
+hopefully everything is running smoothly. With this console you can interact
+directly with the running server. Next, point your browser to:
http://localhost:8001/hello/world
@@ -17,17 +31,23 @@ If all is well you will see "Hello, World!" Now you can get busy.
== The Model Directory: BossRecords ==
-BossRecords are specially compiled parameterized modules. Important aspects of BossRecords:
+BossRecords are specially compiled parameterized modules. Important aspects of
+BossRecords:
- * The first parameter of a BossRecord should always be called Id, and the other parameters should be CamelCased attributes of your data model.
+ * The first parameter of a BossRecord should always be called Id, and the
+ other parameters should be CamelCased attributes of your data model.
- * All parameters will be available as lower-case, underscored functions, e.g. -module(foo, [Id, TheText]) will generate the getter functions id() and the_text(), and the setters id(NewId) and the_text(NewText). Note that setters do not save the BossRecord.
+ * All parameters will be available as lower-case, underscored functions,
+ e.g. -module(foo, [Id, TheText]) will generate the getter functions id()
+ and the_text(), and the setters id(NewId) and the_text(NewText). Note that
+ setters do not save the BossRecord.
* To auto-generate an ID, pass the atom 'id' as the first parameter to "new".
* Call "new" with strings for all other parameters
- * Parameters that end in "Time" (e.g., CreationTime, UpdateTime) should be passed either erlang:now() or a datetime tuple.
+ * Parameters that end in "Time" (e.g., CreationTime, UpdateTime) should be
+ passed either erlang:now() or a datetime tuple.
Generated instance functions of a BossRecord include:
@@ -1 +1,2 @@
-Hello, {{ world }}!
+<h1>{{ greeting.greeting_text }}</h1>
+<p>This is a greeting. Read more about the <code>greeting</code> Model at <a href="/doc/greeting">/doc/greeting</a>
View
@@ -0,0 +1,24 @@
+%% Medici application resource file.
+%%
+%% Add runtime options in the list value for the options property of
+%% env or set them via a config file or the medici:start() function.
+%%
+{application, medici,
+ [{description, "Medici Tokyo Tyrant interface"},
+ {vsn, "0.5"},
+ {modules, [
+ medici,
+ medici_app,
+ medici_sup,
+ medici_controller,
+ medici_native_controller,
+ medici_conn_sup,
+ medici_conn,
+ medici_native_conn,
+ principe,
+ principe_table]},
+ {registered, []},
+ {applications, [kernel, stdlib]},
+ {mod, {medici_app, []}},
+ {env, [{options, []}]}
+ ]}.
View
@@ -0,0 +1,168 @@
+%%% The contents of this file are subject to the Erlang Public License,
+%%% Version 1.1, (the "License"); you may not use this file except in
+%%% compliance with the License. You should have received a copy of the
+%%% Erlang Public License along with this software. If not, it can be
+%%% retrieved via the world wide web at http://www.erlang.org/.
+%%%
+%%% Software distributed under the License is distributed on an "AS IS"
+%%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%%% the License for the specific language governing rights and limitations
+%%% under the License.
+%%%-------------------------------------------------------------------
+%%% File: medici.erl
+%%% @author Jim McCoy <mccoy@mad-scientist.com>
+%%% @copyright Copyright (c) 2009, Jim McCoy. All Rights Reserved.
+%%%
+%%% @doc
+%%% This module provides the primary API for interfacing with the
+%%% medici application. These functions assume you are using the default
+%%% registered name for the service and that you know what sort of remote database
+%%% you are talking to (e.g. don't make table-specific calls to a hash
+%%% database.) If you need byte-order specific ops, want to register the
+%%% controller with a different name, or want to run medici interfaces
+%%% to multiple remote databases within the same erlang VM the you should
+%%% update these or make your own versions to make the appropriate calls
+%%% to the controller.
+%%% @end
+
+-module(medici).
+
+%% Starting and stopping the app
+-export([start/0, start/1, stop/0]).
+
+%% Basic API exports
+-export([put/2, putkeep/2, putcat/2, putshl/3, putnr/2, out/1, get/1,
+ mget/1, vsiz/1, iterinit/0, iternext/0, fwmkeys/2, addint/2,
+ adddouble/2, adddouble/3, sync/0, vanish/0, rnum/0, size/0,
+ stat/0, copy/1, restore/2, setmst/2]).
+
+%% Table API exports
+-export([update/2, setindex/2, genuid/0, query_limit/2, query_limit/3,
+ query_add_condition/4, query_order/3, search/1, searchcount/1,
+ searchout/1]).
+
+
+%% @spec start() -> {ok, Pid} | Error:term()
+%%
+%% @doc Start the medici application.
+start() ->
+ application:start(medici).
+
+%% @spec start(StartupOptions::proplist()) -> {ok, Pid} | Error:term()
+%%
+%% @doc
+%% Start the medici application, using a provided proplist as a set of
+%% additional options for the medici application. WARNING: If you use
+%% start/1 the options you provide will become the new default startup
+%% options until you restart your Erlang VM.
+%% @end
+start(StartupOptions) when is_list(StartupOptions) ->
+ {ok, AppEnvOptions} = application:get_env(medici, options),
+ CombinedOptions = [StartupOptions | AppEnvOptions],
+ MediciOptions = [{K, proplists:get_value(K, CombinedOptions)} ||
+ K <- proplists:get_keys(CombinedOptions)],
+ application:put_env(medici, {options, MediciOptions}),
+ application:start(medici).
+
+stop() ->
+ application:stop(medici).
+
+put(Key, Value) ->
+ gen_server:call(medici, {put, Key, Value}).
+
+putcat(Key, Value) ->
+ gen_server:call(medici, {putcat, Key, Value}).
+
+putkeep(Key, Value) ->
+ gen_server:call(medici, {putkeep, Key, Value}).
+
+putshl(Key, Value, Width) ->
+ gen_server:call(medici, {putshl, Key, Value, Width}).
+
+putnr(Key, Value) ->
+ gen_server:cast(medici, {putnr, Key, Value}).
+
+out(Key) ->
+ gen_server:call(medici, {out, Key}).
+
+get(Key) ->
+ gen_server:call(medici, {get, Key}).
+
+mget(KeyList) ->
+ gen_server:call(medici, {mget, KeyList}).
+
+vsiz(Key) ->
+ gen_server:call(medici, {vsiz, Key}).
+
+iterinit() ->
+ gen_server:call(medici, {iterinit}).
+
+iternext() ->
+ gen_server:call(medici, {iternext}).
+
+fwmkeys(Prefix, MaxKeys) ->
+ gen_server:call(medici, {fwmkeys, Prefix, MaxKeys}).
+
+addint(Key, Int) ->
+ gen_server:call(medici, {addint, Key, Int}).
+
+adddouble(Key, Double) ->
+ gen_server:call(medici, {adddouble, Key, Double}).
+
+adddouble(Key, IntPart, FracPart) ->
+ gen_server:call(medici, {adddouble, Key, IntPart, FracPart}).
+
+sync() ->
+ gen_server:call(medici, {sync}).
+
+vanish() ->
+ gen_server:call(medici, {vanish}).
+
+rnum() ->
+ gen_server:call(medici, {rnum}).
+
+size() ->
+ gen_server:call(medici, {size}).
+
+stat() ->
+ gen_server:call(medici, {stat}).
+
+copy(PathName) ->
+ gen_server:call(medici, {copy, PathName}).
+
+restore(PathName, TimeStamp) ->
+ gen_server:call(medici, {restore, PathName, TimeStamp}).
+
+setmst(HostName, Port) ->
+ gen_server:call(medici, {setmst, HostName, Port}).
+
+%% Additional table functions
+update(Key, NewCols) ->
+ gen_server:call(medici, {update, Key, NewCols}).
+
+setindex(Column, Type) ->
+ gen_server:call(medici, {setindex, Column, Type}).
+
+genuid() ->
+ gen_server:call(medici, {genuid}).
+
+query_limit(OldQuery, Max) ->
+ gen_server:call(medici, {query_limit, OldQuery, Max}).
+
+query_limit(OldQuery, Max, Skip) ->
+ gen_server:call(medici, {query_limit, OldQuery, Max, Skip}).
+
+query_add_condition(OldQuery, Column, Op, ExprList) ->
+ gen_server:call(medici, {query_add_condition, OldQuery, Column, Op, ExprList}).
+
+query_order(OldQuery, Column, Type) ->
+ gen_server:call(medici, {query_order, OldQuery, Column, Type}).
+
+search(Query) ->
+ gen_server:call(medici, {search, Query}).
+
+searchcount(Query) ->
+ gen_server:call(medici, {searchcount, Query}).
+
+searchout(Query) ->
+ gen_server:call(medici, {searchout, Query}).
View
@@ -0,0 +1,38 @@
+%%%-------------------------------------------------------------------
+%%% File : medici.erl
+%%% Author : Jim McCoy <>
+%%% Description :
+%%%
+%%% Created : 7 May 2009 by Jim McCoy <>
+%%%-------------------------------------------------------------------
+-module(medici_app).
+
+-behaviour(application).
+
+%% Application callbacks
+-export([start/2, stop/1]).
+
+%%====================================================================
+%% Application callbacks
+%%====================================================================
+%%--------------------------------------------------------------------
+%% Function: start(Type, StartArgs) -> {ok, Pid} |
+%% {ok, Pid, State} |
+%% {error, Reason}
+%% Description: This function is called whenever an application
+%% is started using application:start/1,2, and should start the processes
+%% of the application. If the application is structured according to the
+%% OTP design principles as a supervision tree, this means starting the
+%% top supervisor of the tree.
+%%--------------------------------------------------------------------
+start(_Type, StartArgs) ->
+ medici_sup:start_link(StartArgs).
+
+%%--------------------------------------------------------------------
+%% Function: stop(State) -> void()
+%% Description: This function is called whenever an application
+%% has stopped. It is intended to be the opposite of Module:start/2 and
+%% should do any necessary cleaning up. The return value is ignored.
+%%--------------------------------------------------------------------
+stop(_State) ->
+ ok.
Oops, something went wrong.

0 comments on commit 788d56f

Please sign in to comment.