|
23 | 23 |
|
24 | 24 | -type fold_fun() :: fun(([term()], Acc::term()) -> Acc::term()).
|
25 | 25 |
|
| 26 | +-behaviour(riak_kv_update_hook). |
| 27 | + |
| 28 | +%% riak_kv_update_hook behaviors |
| 29 | +-export([ |
| 30 | + update/3, |
| 31 | + update_binary/5, |
| 32 | + requires_existing_object/1, |
| 33 | + should_handoff/1 |
| 34 | +]). |
| 35 | + |
26 | 36 | %%%===================================================================
|
27 |
| -%%% API |
| 37 | +%% riak_kv_update_hook behavior |
28 | 38 | %%%===================================================================
|
29 | 39 |
|
30 |
| -%% @doc Index a Riak object, given a reason and partition under which |
31 |
| -%% the object is being indexed. The object pair contains the new |
32 |
| -%% and old objects, in the case where a read-before-write resulted |
33 |
| -%% in an old object we can use to delete siblings before updating. |
34 |
| --spec index(object_pair(), write_reason(), p()) -> ok. |
35 |
| -index(RObjPair, Reason, Idx) -> |
| 40 | +%% @doc see riak_kv_update_hook:update/3 |
| 41 | +-spec update( |
| 42 | + riak_kv_update_hook:object_pair(), |
| 43 | + riak_kv_update_hook:update_reason(), |
| 44 | + riak_kv_update_hook:partition() |
| 45 | +) -> ok. |
| 46 | +update(RObjPair, Reason, Idx) -> |
36 | 47 | yz_kv:index(RObjPair, Reason, Idx).
|
37 | 48 |
|
38 |
| -%% @doc Index a Riak object encoded as a n erlang binary. This function |
39 |
| -%% is typically called from the write-once path, where there is no |
40 |
| -%% old object to |
41 |
| --spec index_binary(bucket(), key(), binary(), write_reason(), p()) -> ok. |
42 |
| -index_binary(Bucket, Key, Bin, Reason, P) -> |
| 49 | +%% @doc see riak_kv_update_hook:update_binary/5 |
| 50 | +-spec update_binary( |
| 51 | + riak_core_bucket:bucket(), |
| 52 | + riak_object:key(), |
| 53 | + binary(), |
| 54 | + riak_kv_update_hook:update_reason(), |
| 55 | + riak_kv_update_hook:partition() |
| 56 | +) -> ok. |
| 57 | +update_binary(Bucket, Key, Bin, Reason, P) -> |
43 | 58 | yz_kv:index_binary(Bucket, Key, Bin, Reason, P).
|
44 | 59 |
|
45 |
| -%% @doc Determine whether a bucket is searchable, based on its properties. |
46 |
| --spec is_searchable(riak_kv_bucket:props()) -> boolean(). |
47 |
| -is_searchable(BProps) -> |
| 60 | +%% @doc see riak_kv_update_hook:requires_existing_object/1 |
| 61 | +-spec requires_existing_object(riak_kv_bucket:props()) -> boolean(). |
| 62 | +requires_existing_object(BProps) -> |
48 | 63 | yz_kv:is_search_enabled_for_bucket(BProps).
|
49 | 64 |
|
| 65 | +%% @doc see riak_kv_update_hook:should_handoff/1 |
| 66 | +-spec should_handoff(riak_kv_update_hook:handoff_dest()) -> boolean(). |
| 67 | +should_handoff(HandoffSpec) -> |
| 68 | + yz_kv:should_handoff(HandoffSpec). |
| 69 | + |
| 70 | + |
| 71 | +%%%=================================================================== |
| 72 | +%%% API |
| 73 | +%%%=================================================================== |
| 74 | + |
50 | 75 | %% @doc Disable the given `Component'. The main reason for disabling
|
51 | 76 | %% a component is to help in diagnosing issues in a live,
|
52 | 77 | %% production environment. E.g. the `search' component may be
|
|
0 commit comments