nickva commented on code in PR #4266: URL: https://github.com/apache/couchdb/pull/4266#discussion_r1026723697
########## src/smoosh/src/smoosh_persist.erl: ########## @@ -0,0 +1,300 @@ +% 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(smoosh_persist). + +-export([ + unpersist/1, + persist/3, + check_setup/0 +]). + +-include_lib("kernel/include/file.hrl"). + +-define(SUFFIX, ".smooshq"). + +% Public API + +unpersist(Name) -> + Enabled = config:get_boolean("smoosh", "persist", false), + Capacity = smoosh_utils:capacity(Name), + unpersist(Enabled, Name, Capacity). + +persist(Waiting, #{} = Active, #{} = Starting) -> + Enabled = config:get_boolean("smoosh", "persist", false), + persist(Enabled, Waiting, Active, Starting). + +% Validate peristence setup for read/write/delete access. Emit warnings if +% there are any failures. Call this function once during startup. During +% runtime errors are ignored. Smoosh persistence is opportunistic, so if we +% cannot read or write we just move on. +% +check_setup() -> Review Comment: Yeah, I was going with the idea that smoosh persistence is kind of opportunistic. If users don't set it up properly, and the state directory is not usable, we don't want to hard crash the nodes or continuously spam the logs. The idea is used in weatherreport, I believe, to check db data directories as well. -- 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]
