summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Mazzoli <francesco@rabbitmq.com>2012-04-02 17:09:58 +0100
committerFrancesco Mazzoli <francesco@rabbitmq.com>2012-04-02 17:09:58 +0100
commit1a83d8af963dfc4869fc85f9c268cf9208d84487 (patch)
tree8a1cd8080ac9d0507f52f1fa623f6824198b54f3
parentc28b3691958928f4e80800518a8fef416b950acc (diff)
downloadrabbitmq-server-1a83d8af963dfc4869fc85f9c268cf9208d84487.tar.gz
Added callback info to rabbit_msg_store.
-rw-r--r--include/rabbit_msg_store_index.hrl45
-rw-r--r--src/rabbit_msg_store_ets_index.erl4
-rw-r--r--src/rabbit_msg_store_index.erl27
3 files changed, 29 insertions, 47 deletions
diff --git a/include/rabbit_msg_store_index.hrl b/include/rabbit_msg_store_index.hrl
deleted file mode 100644
index 75d7eb71..00000000
--- a/include/rabbit_msg_store_index.hrl
+++ /dev/null
@@ -1,45 +0,0 @@
-%% The contents of this file are subject to the Mozilla Public License
-%% Version 1.1 (the "License"); you may not use this file except in
-%% compliance with the License. You may obtain a copy of the License
-%% at http://www.mozilla.org/MPL/
-%%
-%% 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.
-%%
-%% The Original Code is RabbitMQ.
-%%
-%% The Initial Developer of the Original Code is VMware, Inc.
-%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
-%%
-
--include("rabbit_msg_store.hrl").
-
-%%----------------------------------------------------------------------------
-
--ifdef(use_specs).
-
--type(dir() :: any()).
--type(index_state() :: any()).
--type(keyvalue() :: any()).
--type(fieldpos() :: non_neg_integer()).
--type(fieldvalue() :: any()).
-
--spec(new/1 :: (dir()) -> index_state()).
--spec(recover/1 :: (dir()) -> rabbit_types:ok_or_error2(index_state(), any())).
--spec(lookup/2 ::
- (rabbit_types:msg_id(), index_state()) -> ('not_found' | keyvalue())).
--spec(insert/2 :: (keyvalue(), index_state()) -> 'ok').
--spec(update/2 :: (keyvalue(), index_state()) -> 'ok').
--spec(update_fields/3 :: (rabbit_types:msg_id(), ({fieldpos(), fieldvalue()} |
- [{fieldpos(), fieldvalue()}]),
- index_state()) -> 'ok').
--spec(delete/2 :: (rabbit_types:msg_id(), index_state()) -> 'ok').
--spec(delete_object/2 :: (keyvalue(), index_state()) -> 'ok').
--spec(delete_by_file/2 :: (fieldvalue(), index_state()) -> 'ok').
--spec(terminate/1 :: (index_state()) -> any()).
-
--endif.
-
-%%----------------------------------------------------------------------------
diff --git a/src/rabbit_msg_store_ets_index.erl b/src/rabbit_msg_store_ets_index.erl
index 9c31439f..3defeaaf 100644
--- a/src/rabbit_msg_store_ets_index.erl
+++ b/src/rabbit_msg_store_ets_index.erl
@@ -16,6 +16,8 @@
-module(rabbit_msg_store_ets_index).
+-include("rabbit_msg_store.hrl").
+
-behaviour(rabbit_msg_store_index).
-export([new/1, recover/1,
@@ -25,8 +27,6 @@
-define(MSG_LOC_NAME, rabbit_msg_store_ets_index).
-define(FILENAME, "msg_store_index.ets").
--include("rabbit_msg_store_index.hrl").
-
-record(state, { table, dir }).
new(Dir) ->
diff --git a/src/rabbit_msg_store_index.erl b/src/rabbit_msg_store_index.erl
index 2f36256c..6cc0b2a7 100644
--- a/src/rabbit_msg_store_index.erl
+++ b/src/rabbit_msg_store_index.erl
@@ -16,6 +16,31 @@
-module(rabbit_msg_store_index).
+-include("rabbit_msg_store.hrl").
+
+-ifdef(use_specs).
+
+-type(dir() :: any()).
+-type(index_state() :: any()).
+-type(keyvalue() :: any()).
+-type(fieldpos() :: non_neg_integer()).
+-type(fieldvalue() :: any()).
+
+-callback new(dir()) -> index_state().
+-callback recover(dir()) -> rabbit_types:ok_or_error2(index_state(), any()).
+-callback lookup(rabbit_types:msg_id(), index_state()) -> ('not_found' | keyvalue()).
+-callback insert(keyvalue(), index_state()) -> 'ok'.
+-callback update(keyvalue(), index_state()) -> 'ok'.
+-callback update_fields(rabbit_types:msg_id(), ({fieldpos(), fieldvalue()} |
+ [{fieldpos(), fieldvalue()}]),
+ index_state()) -> 'ok'.
+-callback delete(rabbit_types:msg_id(), index_state()) -> 'ok'.
+-callback delete_object(keyvalue(), index_state()) -> 'ok'.
+-callback delete_by_file(fieldvalue(), index_state()) -> 'ok'.
+-callback terminate(index_state()) -> any().
+
+-else.
+
-export([behaviour_info/1]).
behaviour_info(callbacks) ->
@@ -30,3 +55,5 @@ behaviour_info(callbacks) ->
{terminate, 1}];
behaviour_info(_Other) ->
undefined.
+
+-endif.