iilyak commented on code in PR #5491:
URL: https://github.com/apache/couchdb/pull/5491#discussion_r2056473334


##########
src/couch_stats/src/csrt_server.erl:
##########
@@ -0,0 +1,196 @@
+% Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
+%
+% Unless required by applicable law or agreed to in writing, software
+% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+% License for the specific language governing permissions and limitations under
+% the License.
+
+-module(csrt_server).
+
+-behaviour(gen_server).
+
+-export([
+    start_link/0,
+    init/1,
+    handle_call/3,
+    handle_cast/2
+]).
+
+-export([
+    create_pid_ref/0,
+    create_resource/1,
+    destroy_resource/1,
+    get_resource/1,
+    get_context_type/1,
+    inc/2,
+    inc/3,
+    new_context/2,
+    set_context_dbname/2,
+    set_context_username/2,
+    set_context_type/2,
+    update_counter/3
+]).
+
+-include_lib("stdlib/include/ms_transform.hrl").
+-include_lib("couch_stats_resource_tracker.hrl").
+
+-record(st, {}).
+
+%%
+%% Public API
+%%
+
+-spec create_pid_ref() -> pid_ref().
+create_pid_ref() ->
+    {self(), make_ref()}.
+
+%%
+%%
+%% Context lifecycle API
+%%
+
+-spec new_context(Type :: rctx_type(), Nonce :: nonce()) -> rctx().
+new_context(Type, Nonce) ->
+    #rctx{
+        nonce = Nonce,
+        pid_ref = create_pid_ref(),
+        type = Type
+    }.
+
+-spec set_context_dbname(DbName, PidRef) -> boolean() when
+    DbName :: dbname(), PidRef :: maybe_pid_ref().
+set_context_dbname(_, undefined) ->
+    false;
+set_context_dbname(DbName, PidRef) ->
+    update_element(PidRef, [{#rctx.dbname, DbName}]).
+
+%%set_context_handler_fun(_, undefined) ->
+%%    ok;
+%%set_context_handler_fun(Fun, PidRef) when is_function(Fun) ->
+%%    FProps = erlang:fun_info(Fun),
+%%    Mod = proplists:get_value(module, FProps),
+%%    Func = proplists:get_value(name, FProps),
+%%    #rctx{type=#coordinator{}=Coordinator} = get_resource(PidRef),
+%%    Update = [{#rctx.type, Coordinator#coordinator{mod=Mod, func=Func}}],
+%%    update_element(PidRef, Update).
+
+-spec set_context_username(UserName, PidRef) -> boolean() when
+    UserName :: username(), PidRef :: maybe_pid_ref().
+set_context_username(_, undefined) ->
+    ok;

Review Comment:
   The return type defined as `boolean()`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to