Skip to content

Commit

Permalink
Merge pull request #758 from basho/fd-remove-yz-dep-develop29
Browse files Browse the repository at this point in the history
Yokozuna/KV isolation
  • Loading branch information
martinsumner authored Oct 4, 2019
2 parents 5d028e1 + fe3aef4 commit 64dac5a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
8 changes: 8 additions & 0 deletions priv/yokozuna.schema
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@
hidden
]}.

%% @doc Set the riak_kv update hook to be the yokozuna module, which
%% implements the `riak_kv_update_hook` behavior
{mapping, "search.update_hook", "riak_kv.update_hook", [
{datatype, atom},
{default, yokozuna},
hidden
]}.

%%===========================================================
%% Validators
%%===========================================================
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{deps,
[
{kvc, ".*", {git, "git://github.com/etrepum/kvc.git", {tag, "v1.5.0"}}},
{riak_kv, ".*", {git, "git://github.com/basho/riak_kv.git", {tag, "riak_kv-2.9.0"}}},
{riak_kv, ".*", {git, "git://github.com/basho/riak_kv.git", {branch, "fd-remove-yz-dep-develop29"}}},
{ibrowse, "4.0.2", {git, "git://github.com/cmullaparthi/ibrowse.git", {tag, "v4.0.2"}}},
{fuse, "2.1.0", {git, "https://github.com/jlouis/fuse.git", {tag, "v2.1.0"}}},
{riakc, ".*", {git, "git://github.com/basho/riak-erlang-client", {branch, "develop-2.2"}}}
Expand Down
45 changes: 45 additions & 0 deletions src/yokozuna.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,51 @@

-type fold_fun() :: fun(([term()], Acc::term()) -> Acc::term()).

-behaviour(riak_kv_update_hook).

%% riak_kv_update_hook behaviors
-export([
update/3,
update_binary/5,
requires_existing_object/1,
should_handoff/1
]).

%%%===================================================================
%% riak_kv_update_hook behavior
%%%===================================================================

%% @doc see riak_kv_update_hook:update/3
-spec update(
riak_kv_update_hook:object_pair(),
riak_kv_update_hook:update_reason(),
riak_kv_update_hook:partition()
) -> ok.
update(RObjPair, Reason, Idx) ->
yz_kv:index(RObjPair, Reason, Idx).

%% @doc see riak_kv_update_hook:update_binary/5
-spec update_binary(
riak_core_bucket:bucket(),
riak_object:key(),
binary(),
riak_kv_update_hook:update_reason(),
riak_kv_update_hook:partition()
) -> ok.
update_binary(Bucket, Key, Bin, Reason, P) ->
yz_kv:index_binary(Bucket, Key, Bin, Reason, P).

%% @doc see riak_kv_update_hook:requires_existing_object/1
-spec requires_existing_object(riak_kv_bucket:props()) -> boolean().
requires_existing_object(BProps) ->
yz_kv:is_search_enabled_for_bucket(BProps).

%% @doc see riak_kv_update_hook:should_handoff/1
-spec should_handoff(riak_kv_update_hook:handoff_dest()) -> boolean().
should_handoff(HandoffSpec) ->
yz_kv:should_handoff(HandoffSpec).


%%%===================================================================
%%% API
%%%===================================================================
Expand Down
1 change: 1 addition & 0 deletions test/yokozuna_schema_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ basic_schema_test() ->
cuttlefish_unit:assert_config(Config, "yokozuna.aae_throttle_enabled", true),
cuttlefish_unit:assert_not_configured(Config, "yokozuna.aae_throttle_limits"),
cuttlefish_unit:assert_config(Config, "yokozuna.enable_dist_query", true),
cuttlefish_unit:assert_config(Config, "riak_kv.update_hook", yokozuna),
ok.

override_schema_test() ->
Expand Down

0 comments on commit 64dac5a

Please sign in to comment.