Created
August 4, 2014 11:35
-
-
Save rnewson/0a2e1a8e8df1302fa903 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/ioq.erl b/src/ioq.erl | |
index b2be7bf..b863a20 100644 | |
--- a/src/ioq.erl | |
+++ b/src/ioq.erl | |
@@ -12,10 +12,14 @@ | |
-module(ioq). | |
-behaviour(gen_server). | |
+-behaviour(config_listener). | |
-export([start_link/0, call/2]). | |
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, code_change/3, terminate/2]). | |
+% config_listener api | |
+-export([handle_config_change/5]). | |
+ | |
-record(state, { | |
concurrency, | |
ratio, | |
@@ -78,6 +82,13 @@ code_change(_Vsn, State, _Extra) -> | |
terminate(_Reason, _State) -> | |
ok. | |
+handle_config_change("ioq", "ratio", NewRatio, _, State) -> | |
+ {ok, State#state{ratio = NewRatio}}; | |
+handle_config_change("ioq", "concurrency", NewConcurrency, _, State) -> | |
+ {ok, State#state{concurrency = NewConcurrency}}; | |
+handle_config_change(_, _, _, _, State) -> | |
+ {ok, State}. | |
+ | |
enqueue_request(#request{class=compaction}=Request, #state{}=State) -> | |
State#state{compaction=queue:in(Request, State#state.compaction)}; | |
enqueue_request(#request{}=Request, #state{}=State) -> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment