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 +4 -4
- data/CHANGELOG.md +8 -0
- data/ext/iodine/iodine_connection.c +26 -0
- data/ext/iodine/scheduler.c +33 -3
- data/lib/iodine/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 631b44322a680678bf03e03a8a52b5926a4890947b8ce994df658d35076d5cbc
|
4
|
+
data.tar.gz: 1bd25cc3fef7949c0dbafcdf1c1099cd654d2f15d3ba3aa61f7fcfd96cdbd922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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);
|
data/ext/iodine/scheduler.c
CHANGED
@@ -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
|
-
|
78
|
-
|
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
|
-
|
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
|
|
data/lib/iodine/version.rb
CHANGED
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.
|
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:
|
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.
|
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
|