Skip to content

Commit f1cc8de

Browse files
authored
Merge pull request #5627 from apache/nouveau-improvements
Nouveau improvements
2 parents d16fc1f + f0d7810 commit f1cc8de

File tree

2 files changed

+19
-31
lines changed

2 files changed

+19
-31
lines changed

src/nouveau/src/nouveau_api.erl

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -217,37 +217,20 @@ set_seq(#index{} = Index, ReqBody) ->
217217
%% private functions
218218

219219
index_path(Path) when is_binary(Path) ->
220-
lists:flatten(
221-
io_lib:format(
222-
"/index/~s",
223-
[
224-
couch_util:url_encode(Path)
225-
]
226-
)
227-
);
220+
[<<"/index/">>, couch_util:url_encode(Path)];
228221
index_path(#index{} = Index) ->
229-
lists:flatten(
230-
io_lib:format(
231-
"/index/~s",
232-
[
233-
couch_util:url_encode(nouveau_util:index_name(Index))
234-
]
235-
)
236-
).
222+
[<<"/index/">>, couch_util:url_encode(nouveau_util:index_name(Index))].
237223

238224
doc_path(#index{} = Index, DocId) ->
239-
lists:flatten(
240-
io_lib:format(
241-
"/index/~s/doc/~s",
242-
[
243-
couch_util:url_encode(nouveau_util:index_name(Index)),
244-
couch_util:url_encode(DocId)
245-
]
246-
)
247-
).
225+
[
226+
<<"/index/">>,
227+
couch_util:url_encode(nouveau_util:index_name(Index)),
228+
<<"/doc/">>,
229+
couch_util:url_encode(DocId)
230+
].
248231

249-
search_path(IndexName) ->
250-
index_path(IndexName) ++ "/search".
232+
search_path(#index{} = Index) ->
233+
[index_path(Index), <<"/search">>].
251234

252235
jaxrs_error(400, Body) ->
253236
{bad_request, message(Body)};
@@ -281,6 +264,9 @@ send_if_enabled(Path, ReqHeaders, Method) ->
281264
send_if_enabled(Path, ReqHeaders, Method, <<>>).
282265

283266
send_if_enabled(Path, ReqHeaders, Method, ReqBody) ->
267+
send_if_enabled(Path, ReqHeaders, Method, ReqBody, 5).
268+
269+
send_if_enabled(Path, ReqHeaders, Method, ReqBody, RemainingTries) ->
284270
case nouveau:enabled() of
285271
true ->
286272
case
@@ -306,6 +292,9 @@ send_if_enabled(Path, ReqHeaders, Method, ReqBody) ->
306292
{error, Reason} ->
307293
{error, Reason}
308294
end;
295+
{error, no_connection_available, _Reason} when RemainingTries > 0 ->
296+
timer:sleep(1000),
297+
send_if_enabled(Path, ReqHeaders, Method, ReqBody, RemainingTries - 1);
309298
{error, _Type, Reason} ->
310299
{error, Reason}
311300
end;

src/nouveau/src/nouveau_util.erl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,15 @@ design_doc_to_index(DbName, #doc{id = Id, body = {Fields}}, IndexName) ->
7373
undefined ->
7474
{error, InvalidDDocError};
7575
Def ->
76-
Sig = ?l2b(
77-
couch_util:to_hex(
76+
Sig =
77+
couch_util:to_hex_bin(
7878
crypto:hash(
7979
sha256,
8080
?term_to_bin(
8181
{DefaultAnalyzer, FieldAnalyzers, Def}
8282
)
8383
)
84-
)
85-
),
84+
),
8685
{ok, #index{
8786
dbname = DbName,
8887
default_analyzer = DefaultAnalyzer,

0 commit comments

Comments
 (0)