Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yokozuna/KV isolation #758

Merged
merged 2 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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