durable_rules 0.33.13 → 0.34.01

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/src/rules/net.h CHANGED
@@ -30,6 +30,7 @@ typedef struct binding {
30
30
  functionHash removeActionHash;
31
31
  functionHash partitionHash;
32
32
  functionHash timersHash;
33
+ functionHash updateActionHash;
33
34
  char *sessionHashset;
34
35
  char *factsHashset;
35
36
  char *eventsHashset;
@@ -132,10 +133,19 @@ unsigned int registerTimer(void *rulesBinding,
132
133
  unsigned int duration,
133
134
  char *timer);
134
135
 
136
+ unsigned int removeTimer(void *rulesBinding,
137
+ char *timer);
138
+
139
+ unsigned int registerMessage(void *rulesBinding,
140
+ char *destination,
141
+ char *message);
142
+
135
143
  unsigned int deleteBindingsList(ruleset *tree);
136
144
 
137
145
  unsigned int getSession(void *rulesBinding,
138
146
  char *sid,
139
147
  char **state);
140
148
 
149
+ unsigned int updateAction(void *rulesBinding,
150
+ char *sid);
141
151
 
data/src/rules/rules.h CHANGED
@@ -31,6 +31,7 @@
31
31
  #define ERR_NO_ACTION_AVAILABLE 303
32
32
  #define ERR_NO_TIMERS_AVAILABLE 304
33
33
  #define ERR_NEW_SESSION 305
34
+ #define ERR_TRY_AGAIN 306
34
35
  #define ERR_STATE_CACHE_FULL 401
35
36
  #define ERR_BINDING_NOT_MAPPED 402
36
37
  #define ERR_STATE_NOT_LOADED 403
@@ -156,12 +157,24 @@ unsigned int startTimer(void *handle,
156
157
  unsigned int duration,
157
158
  char *timer);
158
159
 
160
+ unsigned int cancelTimer(void *handle,
161
+ char *sid,
162
+ char *timer);
163
+
164
+ unsigned int queueMessage(void *handle,
165
+ char *sid,
166
+ char *destination,
167
+ char *message);
168
+
159
169
  unsigned int assertTimers(void *handle);
160
170
 
161
171
  unsigned int getState(void *handle,
162
172
  char *sid,
163
173
  char **state);
164
174
 
175
+ unsigned int renewActionLease(void *handle,
176
+ char *sid);
177
+
165
178
  #ifdef _WIN32
166
179
  int asprintf(char** ret, char* format, ...);
167
180
  #endif
data/src/rulesrb/rules.c CHANGED
@@ -124,6 +124,24 @@ static VALUE rbAssertEvent(VALUE self, VALUE handle, VALUE event) {
124
124
  return Qnil;
125
125
  }
126
126
 
127
+ static VALUE rbQueueEvent(VALUE self, VALUE handle, VALUE sid, VALUE destination, VALUE event) {
128
+ Check_Type(handle, T_FIXNUM);
129
+ Check_Type(sid, T_STRING);
130
+ Check_Type(destination, T_STRING);
131
+ Check_Type(event, T_STRING);
132
+
133
+ unsigned int result = queueMessage((void *)FIX2LONG(handle), RSTRING_PTR(sid), RSTRING_PTR(destination), RSTRING_PTR(event));
134
+ if (result != RULES_OK) {
135
+ if (result == ERR_OUT_OF_MEMORY) {
136
+ rb_raise(rb_eNoMemError, "Out of memory");
137
+ } else {
138
+ rb_raise(rb_eException, "Could not queue event, error code: %d", result);
139
+ }
140
+ }
141
+
142
+ return Qnil;
143
+ }
144
+
127
145
  static VALUE rbStartAssertEvents(VALUE self, VALUE handle, VALUE events) {
128
146
  Check_Type(handle, T_FIXNUM);
129
147
  Check_Type(events, T_STRING);
@@ -573,6 +591,23 @@ static VALUE rbStartTimer(VALUE self, VALUE handle, VALUE sid, VALUE duration, V
573
591
  return Qnil;
574
592
  }
575
593
 
594
+ static VALUE rbCancelTimer(VALUE self, VALUE handle, VALUE sid, VALUE timer) {
595
+ Check_Type(handle, T_FIXNUM);
596
+ Check_Type(sid, T_STRING);
597
+ Check_Type(timer, T_STRING);
598
+
599
+ unsigned int result = cancelTimer((void *)FIX2LONG(handle), RSTRING_PTR(sid), RSTRING_PTR(timer));
600
+ if (result != RULES_OK) {
601
+ if (result == ERR_OUT_OF_MEMORY) {
602
+ rb_raise(rb_eNoMemError, "Out of memory");
603
+ } else {
604
+ rb_raise(rb_eException, "Could not cancel timer, error code: %d", result);
605
+ }
606
+ }
607
+
608
+ return Qnil;
609
+ }
610
+
576
611
  static VALUE rbAssertTimers(VALUE self, VALUE handle) {
577
612
  Check_Type(handle, T_FIXNUM);
578
613
 
@@ -611,6 +646,23 @@ static VALUE rbGetState(VALUE self, VALUE handle, VALUE sid) {
611
646
  return output;
612
647
  }
613
648
 
649
+
650
+ static VALUE rbRenewActionLease(VALUE self, VALUE handle, VALUE sid) {
651
+ Check_Type(handle, T_FIXNUM);
652
+ Check_Type(sid, T_STRING);
653
+
654
+ unsigned int result = renewActionLease((void *)FIX2LONG(handle), RSTRING_PTR(sid));
655
+ if (result != RULES_OK) {
656
+ if (result == ERR_OUT_OF_MEMORY) {
657
+ rb_raise(rb_eNoMemError, "Out of memory");
658
+ } else {
659
+ rb_raise(rb_eException, "Could not renew action lease, error code: %d", result);
660
+ }
661
+ }
662
+
663
+ return Qnil;
664
+ }
665
+
614
666
  void Init_rules() {
615
667
  rulesModule = rb_define_module("Rules");
616
668
  rb_define_singleton_method(rulesModule, "create_ruleset", rbCreateRuleset, 3);
@@ -618,6 +670,7 @@ void Init_rules() {
618
670
  rb_define_singleton_method(rulesModule, "bind_ruleset", rbBindRuleset, 4);
619
671
  rb_define_singleton_method(rulesModule, "complete", rbComplete, 2);
620
672
  rb_define_singleton_method(rulesModule, "assert_event", rbAssertEvent, 2);
673
+ rb_define_singleton_method(rulesModule, "queue_event", rbQueueEvent, 4);
621
674
  rb_define_singleton_method(rulesModule, "start_assert_event", rbStartAssertEvent, 2);
622
675
  rb_define_singleton_method(rulesModule, "assert_events", rbAssertEvents, 2);
623
676
  rb_define_singleton_method(rulesModule, "start_assert_events", rbStartAssertEvents, 2);
@@ -637,8 +690,10 @@ void Init_rules() {
637
690
  rb_define_singleton_method(rulesModule, "complete_and_start_action", rbCompleteAndStartAction, 3);
638
691
  rb_define_singleton_method(rulesModule, "abandon_action", rbAbandonAction, 2);
639
692
  rb_define_singleton_method(rulesModule, "start_timer", rbStartTimer, 4);
693
+ rb_define_singleton_method(rulesModule, "cancel_timer", rbCancelTimer, 3);
640
694
  rb_define_singleton_method(rulesModule, "assert_timers", rbAssertTimers, 1);
641
695
  rb_define_singleton_method(rulesModule, "get_state", rbGetState, 2);
696
+ rb_define_singleton_method(rulesModule, "renew_action_lease", rbRenewActionLease, 2);
642
697
  }
643
698
 
644
699
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: durable_rules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.33.13
4
+ version: 0.34.01
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesus Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -91,6 +91,7 @@ files:
91
91
  - deps/hiredis/dict.c
92
92
  - deps/hiredis/hiredis.c
93
93
  - deps/hiredis/net.c
94
+ - deps/hiredis/read.c
94
95
  - deps/hiredis/sds.c
95
96
  - deps/hiredis/test.c
96
97
  - deps/hiredis/async.h
@@ -98,8 +99,9 @@ files:
98
99
  - deps/hiredis/fmacros.h
99
100
  - deps/hiredis/hiredis.h
100
101
  - deps/hiredis/net.h
102
+ - deps/hiredis/read.h
101
103
  - deps/hiredis/sds.h
102
- - deps/hiredis/zmalloc.h
104
+ - deps/hiredis/win32.h
103
105
  - deps/hiredis/COPYING
104
106
  - deps/hiredis/Makefile
105
107
  - librb/durable.rb
@@ -1,13 +0,0 @@
1
- /* Drop in replacement for zmalloc.h in order to just use libc malloc without
2
- * any wrappering. */
3
-
4
- #ifndef ZMALLOC_H
5
- #define ZMALLOC_H
6
-
7
- #define zmalloc malloc
8
- #define zrealloc realloc
9
- #define zcalloc(x) calloc(x,1)
10
- #define zfree free
11
- #define zstrdup strdup
12
-
13
- #endif