statsrb 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/ext/statsrb/statsrb.c +6 -3
  2. metadata +1 -1
@@ -327,7 +327,8 @@ static VALUE statsrb_rack_call(VALUE self, VALUE env) {
327
327
 
328
328
  int data_length = RARRAY_LEN(statsrb_data);
329
329
  rb_ary_push(body, rb_obj_as_string(INT2NUM(RARRAY_LEN(statsrb_data))));
330
- if (data_length > 9) {
330
+
331
+ if (data_length > NUM2INT(rb_iv_get(self, "@flush_count"))) {
331
332
  statsrb_sort(self);
332
333
  statsrb_split_write(self, rb_iv_get(self, "@split_file_dir"), rb_str_new2("a+"));
333
334
  rb_ary_resize(statsrb_data, 0);
@@ -460,6 +461,7 @@ static VALUE statsrb_constructor(VALUE self) {
460
461
  rb_iv_set(self, "@data", statsrb_data);
461
462
  VALUE statsrb_split_file_dir = rb_str_new("/tmp", 4);
462
463
  rb_iv_set(self, "@split_file_dir", statsrb_split_file_dir);
464
+ rb_iv_set(self, "@flush_count", INT2NUM(9));
463
465
 
464
466
  // Internal symbols for :ts, :ns and :v.
465
467
  VALUE statsrb_key_ts = rb_str_intern(rb_str_new2("ts"));
@@ -489,9 +491,10 @@ void Init_statsrb(void) {
489
491
  rb_define_method(klass, "call", statsrb_rack_call, 1);
490
492
  // Define :attr_accessor (read/write instance var)
491
493
  // Note that this must correspond with a call to rb_iv_self() and it's string name must be @data.
492
- // An array of hashes keyed with :ts(timestamp), :ns(namespace) and :v(value)
493
- // e.g. [!{:ts => Time.now.to_i, :ns => "test", :v => 33}]
494
+ // An array of hashes keyed with :ts(timestamp), :ns(namespace) and :v(value) e.g. [!{:ts => Time.now.to_i, :ns => "test", :v => 33}]
494
495
  rb_define_attr(klass, "data", 1, 1);
495
496
  // The file directory to write when splitting namespaces. @see #split_write
496
497
  rb_define_attr(klass, "split_file_dir", 1, 1);
498
+ // When used with a rack server, the max count of @data before flushing and writing to file.
499
+ rb_define_attr(klass, "flush_count", 1, 1);
497
500
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: