kocolosk commented on a change in pull request #1658: Enable cluster 
auto-assembly through a seedlist
URL: https://github.com/apache/couchdb/pull/1658#discussion_r228292146
 
 

 ##########
 File path: src/mem3/src/mem3_seeds.erl
 ##########
 @@ -0,0 +1,163 @@
+% 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(mem3_seeds).
+-behaviour(gen_server).
+
+-export([
+    init/1,
+    handle_call/3,
+    handle_cast/2,
+    handle_info/2,
+    code_change/3,
+    terminate/2
+]).
+
+-export([
+    start_link/0,
+    get_seeds/0,
+    get_status/0
+]).
+
+-record(st, {
+    ready = false,
+    seeds = [],
+    jobref = nil,
+    status = [] % nested proplist keyed on node name
+}).
+
+-define(REPLICATION_INTERVAL, 60000).
+
+start_link() ->
+    gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
+
+get_seeds() ->
+    case config:get("cluster", "seedlist") of
+        undefined ->
+            [];
+        List ->
+            Nodes = string:tokens(List, ","),
+            Seeds = [list_to_atom(Node) || Node <- Nodes] -- [node()],
+            mem3_util:rotate_list(node(), Seeds)
+    end.
+
+get_status() ->
+    gen_server:call(?MODULE, get_status).
+
+init([]) ->
+    Seeds = get_seeds(),
 
 Review comment:
   I don’t expect that use case as the whole seed list feature is really built 
to make the node initialization process more robust. Would adding a seed cause 
_up to flip back to 404 if no seed had previously been contacted? Lots of weird 
stuff there.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to