ernie 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 2
2
+ :patch: 3
3
3
  :major: 0
4
4
  :minor: 3
data/bin/ernie CHANGED
@@ -68,9 +68,10 @@ OptionParser.new do |opts|
68
68
  end.parse!
69
69
 
70
70
  if command = ARGV[0]
71
- if !%w{reload-handlers}.include?(command)
71
+ if !%w{reload-handlers stats}.include?(command)
72
72
  puts "Invlalid command. Valid commands are:"
73
73
  puts " reload-handlers"
74
+ puts " stats"
74
75
  exit(1)
75
76
  end
76
77
 
data/elib/asset_pool.erl CHANGED
@@ -2,7 +2,7 @@
2
2
  -behaviour(gen_server).
3
3
 
4
4
  %% api
5
- -export([start_link/1, start/1, lease/0, return/1, reload_assets/0]).
5
+ -export([start_link/1, start/1, lease/0, return/1, reload_assets/0, idle_worker_count/0]).
6
6
 
7
7
  %% gen_server callbacks
8
8
  -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
@@ -31,6 +31,9 @@ return(Asset) ->
31
31
  reload_assets() ->
32
32
  gen_server:call({global, ?MODULE}, {reload_assets}).
33
33
 
34
+ idle_worker_count() ->
35
+ gen_server:call({global, ?MODULE}, {idle_worker_count}).
36
+
34
37
  %%====================================================================
35
38
  %% gen_server callbacks
36
39
  %%====================================================================
@@ -91,6 +94,9 @@ handle_call({return, Asset}, _From, State) ->
91
94
  handle_call({reload_assets}, _From, State) ->
92
95
  Token = make_ref(),
93
96
  {reply, ok, State#state{token = Token}};
97
+ handle_call({idle_worker_count}, _From, State) ->
98
+ WorkerCount = queue:len(State#state.assets),
99
+ {reply, WorkerCount, State};
94
100
  handle_call(_Request, _From, State) ->
95
101
  {reply, ok, State}.
96
102
 
@@ -126,6 +126,14 @@ process_admin(Sock, reload_handlers, _Args, State) ->
126
126
  gen_tcp:send(Sock, term_to_binary({reply, <<"Handlers reloaded.">>})),
127
127
  ok = gen_tcp:close(Sock),
128
128
  State;
129
+ process_admin(Sock, stats, _Args, State) ->
130
+ IdleWorkers = asset_pool:idle_worker_count(),
131
+ IdleWorkersString = list_to_binary([<<"idle workers: ">>, integer_to_list(IdleWorkers), <<"\n">>]),
132
+ QueueLength = queue:len(State#state.pending),
133
+ QueueLengthString = list_to_binary([<<"pending connections: ">>, integer_to_list(QueueLength), <<"\n">>]),
134
+ gen_tcp:send(Sock, term_to_binary({reply, list_to_binary([IdleWorkersString, QueueLengthString])})),
135
+ ok = gen_tcp:close(Sock),
136
+ State;
129
137
  process_admin(Sock, _Fun, _Args, State) ->
130
138
  gen_tcp:send(Sock, term_to_binary({reply, <<"Admin function not supported.">>})),
131
139
  ok = gen_tcp:close(Sock),
data/ernie.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ernie}
5
- s.version = "0.3.2"
5
+ s.version = "0.3.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Tom Preston-Werner"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ernie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner