rage-iodine 4.0.0 → 4.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26936e113c659cee25877d312515e6fe50ca5ed56ff5e8195e6f5274292f2145
4
- data.tar.gz: 40b7aa9c791a5bc08513e5e0c478c02274a39c81d9be0fab7736f8478157ffab
3
+ metadata.gz: 631b44322a680678bf03e03a8a52b5926a4890947b8ce994df658d35076d5cbc
4
+ data.tar.gz: 1bd25cc3fef7949c0dbafcdf1c1099cd654d2f15d3ba3aa61f7fcfd96cdbd922
5
5
  SHA512:
6
- metadata.gz: 1a789b92abed8d78b010ace73cb41d1688ff50c4fc6b590b6705a717196c212721039e252461ba8834a8f0bcd43679fc9c611a9f4d4690a826f3ac212bb3b9e5
7
- data.tar.gz: 446a4ecf05a3b371266ea71a92cb514d9a510d2c0fb6dc72e212ff26253e60c343bfc1675a68e6f3c9985c267b9940e61492706f4e61d89e6cb73dbba6c05a2c
6
+ metadata.gz: 0d60eb883de1b8910802143a0c69040b32a1e7b9454c493b3dd76e8fa30415488fce2933633735ae84aa2803ac2aa05337861819f7d6ade82a63a4b57e272815
7
+ data.tar.gz: 5164ae32d754a6f1b6ceda150d416b0eac152cd3d0c17871232da30e1625c2ab4d85419fa1c673f4f217ca9feabaf8b69a4c007665988c7f3e54e682072903d5
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ Please notice that this change log contains changes for upcoming releases as wel
6
6
 
7
7
  ## Changes:
8
8
 
9
+ #### Change log v.4.2.0 (2025-07-23)
10
+
11
+ **Update**: Add `Iodine.subscribed?`.
12
+
13
+ #### Change log v.4.1.0 (2025-02-07)
14
+
15
+ **Update**: Correctly handle `0` timeouts.
16
+
9
17
  #### Change log v.4.0.0 (2024-09-11)
10
18
 
11
19
  **Update**: Stop disconnecting from the DB on fork.
@@ -692,6 +692,30 @@ static VALUE iodine_pubsub_unsubscribe(VALUE self, VALUE name) {
692
692
  return ret;
693
693
  }
694
694
 
695
+ static VALUE iodine_pubsub_is_subscribed(VALUE self, VALUE name) {
696
+ // clang-format on
697
+ iodine_connection_data_s *c = NULL;
698
+ fio_lock_i *s_lock = &sub_lock;
699
+ fio_subhash_s *subs = &sub_global;
700
+ VALUE ret;
701
+ if (TYPE(self) != T_MODULE) {
702
+ c = iodine_connection_validate_data(self);
703
+ if (!c || c->info.uuid == -1) {
704
+ return Qfalse; /* the connection is closed */
705
+ }
706
+ s_lock = &c->lock;
707
+ subs = &c->subscriptions;
708
+ }
709
+ if (TYPE(name) == T_SYMBOL)
710
+ name = rb_sym2str(name);
711
+ Check_Type(name, T_STRING);
712
+ fio_lock(s_lock);
713
+ ret = iodine_sub_find(subs, IODINE_RSTRINFO(name));
714
+ fio_unlock(s_lock);
715
+
716
+ return ret;
717
+ }
718
+
695
719
  // clang-format off
696
720
  /**
697
721
  Publishes a message to a channel.
@@ -935,6 +959,8 @@ void iodine_connection_init(void) {
935
959
  // define global methods
936
960
  rb_define_module_function(IodineModule, "subscribe", iodine_pubsub_subscribe,
937
961
  -1);
962
+ rb_define_module_function(IodineModule, "subscribed?",
963
+ iodine_pubsub_is_subscribed, 1);
938
964
  rb_define_module_function(IodineModule, "unsubscribe",
939
965
  iodine_pubsub_unsubscribe, 1);
940
966
  rb_define_module_function(IodineModule, "publish", iodine_pubsub_publish, -1);
@@ -17,6 +17,7 @@ static uint8_t ATTACH_ON_READ_READY_CALLBACK;
17
17
  static uint8_t ATTACH_ON_WRITE_READY_CALLBACK;
18
18
  static VALUE e_timeout_args[1];
19
19
  static VALUE e_closed_args[1];
20
+ static VALUE e_not_ready_args[1];
20
21
 
21
22
  /* *****************************************************************************
22
23
  Fiber Scheduler API
@@ -58,6 +59,25 @@ static void iodine_scheduler_task_perform(intptr_t uuid, fio_protocol_s *fio_pro
58
59
  (void)uuid;
59
60
  }
60
61
 
62
+ static void iodine_scheduler_task_not_ready(void *uuid, void *fio_protocol) {
63
+ scheduler_protocol_s *protocol = (scheduler_protocol_s *)fio_protocol;
64
+
65
+ if (!protocol->fulfilled) {
66
+ IodineCaller.call2(protocol->block, call_id, 1, e_not_ready_args);
67
+ protocol->fulfilled = 1;
68
+ }
69
+
70
+ (void)uuid;
71
+ }
72
+
73
+ static void iodine_scheduler_task_deferred_not_ready(intptr_t uuid, fio_protocol_s *fio_protocol) {
74
+ // if there's a read event, `fio_defer` will give it time to fulfill the protocol first;
75
+ // otherwise, the fiber will be resumed with `false` indicating the IO is not ready
76
+ fio_defer(iodine_scheduler_task_not_ready, (void *)uuid, (void *)fio_protocol);
77
+
78
+ (void)uuid;
79
+ }
80
+
61
81
  static void iodine_scheduler_task_timeout(intptr_t uuid, fio_protocol_s *fio_protocol) {
62
82
  scheduler_protocol_s *protocol = (scheduler_protocol_s *)fio_protocol;
63
83
 
@@ -74,8 +94,11 @@ static VALUE iodine_scheduler_attach(VALUE self, VALUE r_fd, VALUE r_waittype, V
74
94
  Check_Type(r_waittype, T_FIXNUM);
75
95
  size_t waittype = FIX2UINT(r_waittype);
76
96
 
77
- Check_Type(r_timeout, T_FIXNUM);
78
- size_t timeout = FIX2UINT(r_timeout);
97
+ size_t timeout;
98
+ if (r_timeout != Qnil) {
99
+ Check_Type(r_timeout, T_FIXNUM);
100
+ timeout = FIX2UINT(r_timeout);
101
+ }
79
102
 
80
103
  fio_set_non_block(fd);
81
104
 
@@ -112,8 +135,14 @@ static VALUE iodine_scheduler_attach(VALUE self, VALUE r_fd, VALUE r_waittype, V
112
135
  }
113
136
 
114
137
  intptr_t uuid = fio_fd2uuid(fd);
115
- if (timeout) {
138
+
139
+ if (r_timeout == Qnil) {
140
+ fio_timeout_set(uuid, 0);
141
+ } else if (timeout) {
116
142
  fio_timeout_set(uuid, timeout);
143
+ } else {
144
+ // timeout was explicitly set to 0 - return right away
145
+ protocol->p.on_ready = iodine_scheduler_task_deferred_not_ready;
117
146
  }
118
147
 
119
148
  fio_watch(uuid, (fio_protocol_s *)protocol);
@@ -185,6 +214,7 @@ void iodine_scheduler_initialize(void) {
185
214
  call_id = rb_intern2("call", 4);
186
215
  e_timeout_args[0] = INT2NUM(-ETIMEDOUT);
187
216
  e_closed_args[0] = INT2NUM(-EIO);
217
+ e_not_ready_args[0] = Qfalse;
188
218
 
189
219
  VALUE SchedulerModule = rb_define_module_under(IodineModule, "Scheduler");
190
220
 
@@ -1,3 +1,3 @@
1
1
  module Iodine
2
- VERSION = '4.0.0'.freeze
2
+ VERSION = '4.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rage-iodine
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-09-11 00:00:00.000000000 Z
10
+ date: 2025-07-23 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -252,7 +251,6 @@ licenses:
252
251
  - MIT
253
252
  metadata:
254
253
  allowed_push_host: https://rubygems.org
255
- post_install_message:
256
254
  rdoc_options: []
257
255
  require_paths:
258
256
  - lib
@@ -274,8 +272,7 @@ requirements:
274
272
  - Ruby >= 2.5.0 recommended.
275
273
  - TLS requires OpenSSL >= 1.1.0.
276
274
  - Or Windows with Ruby >= 3.0.0 build with MingW and MingW as compiler.
277
- rubygems_version: 3.4.10
278
- signing_key:
275
+ rubygems_version: 3.6.2
279
276
  specification_version: 4
280
277
  summary: iodine - a fast HTTP / Websocket Server with Pub/Sub support, optimized for
281
278
  Ruby MRI on Linux / BSD / Windows