eventbus-grpc 0.38.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1cf3ed609a42f1d8e532f88959cd4b69e880a8f12df1d8b17f9ad7b77ead9252
4
+ data.tar.gz: 2f20716a1137394e361c183fe85aba7de4e7ab70a83c0a2f5083093b8057c1ca
5
+ SHA512:
6
+ metadata.gz: 31ad0699e57c391b2c0ec17097e3fb0baa7700bc70c0602640996b1a49618f8a8d57692c5c7cb6080a1aec8a70785eef9b6e95e2d000adfb47f8dce2b534be98
7
+ data.tar.gz: 4b32f82a353305df0f89e2742ad25b643b1f519693ac803e523ae4324915b67184c9d621dadeaed209f0016bc3fc82b59d3ae1d8eceeb8158d59cb33c9174d3e
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 John Davis
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # eventbus-grpc (Ruby)
2
+
3
+ Event bus over gRPC — generated grpcdc.events.v1 publish/subscribe clients over WebRTC DataChannels, via the grpc-dc runtime (Ruby).
4
+
5
+ Install: `gem install eventbus-grpc` (depends on `grpc-dc`).
@@ -0,0 +1,2 @@
1
+ require_relative "grpcdc/events_pb"
2
+ require_relative "grpcdc/events_grpc_dc"
@@ -0,0 +1,232 @@
1
+ # Generated code: use without restriction (see GENERATED-CODE-LICENSE.md).
2
+ # @generated by protoc-gen-grpc-dc-ruby. DO NOT EDIT.
3
+ # source: events.proto
4
+
5
+ require_relative "events_pb"
6
+ require "grpcdc"
7
+
8
+ module EventsGrpcDc
9
+ # Client receiving stream: recv raises EOFError at end.
10
+ class RecvStream
11
+ include Enumerable
12
+
13
+ def initialize(stream, resp_cls)
14
+ @stream = stream
15
+ @resp_cls = resp_cls
16
+ end
17
+
18
+ def recv
19
+ @stream.recv(@resp_cls.new)
20
+ end
21
+
22
+ # Response initial metadata (after the first recv).
23
+ def headers
24
+ @stream.headers&.metadata
25
+ end
26
+
27
+ # Response trailing metadata (after the call ends).
28
+ def trailers
29
+ @stream.trailers
30
+ end
31
+
32
+ # Abandon the call early: RST so the server stops producing.
33
+ def cancel
34
+ @stream.cancel
35
+ end
36
+
37
+ def close
38
+ @stream.cancel
39
+ end
40
+
41
+ def each
42
+ return enum_for(:each) unless block_given?
43
+
44
+ begin
45
+ loop do
46
+ begin
47
+ yield recv
48
+ rescue EOFError
49
+ return
50
+ end
51
+ end
52
+ ensure
53
+ # Breaking out of the block abandons the call: RST so
54
+ # the server stops producing (no-op once terminated).
55
+ close
56
+ end
57
+ end
58
+ end
59
+
60
+ # Server-streaming sink passed to service implementations.
61
+ class SendStream
62
+ attr_reader :context
63
+
64
+ def initialize(ctx, sink)
65
+ @context = ctx
66
+ @sink = sink
67
+ end
68
+
69
+ def send(resp)
70
+ @sink.send(resp.marshal_dc)
71
+ end
72
+ end
73
+
74
+ # Client-streaming stream passed to service implementations.
75
+ class ClientStreamImpl
76
+ attr_reader :context, :resp
77
+
78
+ def initialize(ctx, reqs, req_cls)
79
+ @context = ctx
80
+ @reqs = reqs
81
+ @req_cls = req_cls
82
+ @resp = nil
83
+ end
84
+
85
+ def recv
86
+ @reqs.recv_into(@req_cls.new)
87
+ end
88
+
89
+ def send_and_close(resp)
90
+ @resp = resp
91
+ end
92
+ end
93
+
94
+ # Bidi stream passed to service implementations.
95
+ class BidiStream
96
+ attr_reader :context
97
+
98
+ def initialize(ctx, reqs, sink, req_cls)
99
+ @context = ctx
100
+ @reqs = reqs
101
+ @sink = sink
102
+ @req_cls = req_cls
103
+ end
104
+
105
+ def send(resp)
106
+ @sink.send(resp.marshal_dc)
107
+ end
108
+
109
+ def recv
110
+ @reqs.recv_into(@req_cls.new)
111
+ end
112
+ end
113
+
114
+ # Fiber-based client receiving stream: a producer Fiber
115
+ # yields each response; next_msg resumes it and raises
116
+ # StopIteration when the call completes. cancel aborts
117
+ # the underlying stream (RST).
118
+ class FiberRecvStream
119
+ include Enumerable
120
+
121
+ DONE = Object.new
122
+
123
+ def initialize(stream, resp_cls)
124
+ @stream = stream
125
+ @resp_cls = resp_cls
126
+ @fiber = Fiber.new do
127
+ begin
128
+ loop { Fiber.yield(@stream.recv(@resp_cls.new)) }
129
+ rescue EOFError
130
+ DONE
131
+ end
132
+ end
133
+ end
134
+
135
+ def next_msg
136
+ value = @fiber.resume
137
+ raise StopIteration if value.equal?(DONE)
138
+
139
+ value
140
+ end
141
+
142
+ # Response initial metadata (after the first recv).
143
+ def headers
144
+ @stream.headers&.metadata
145
+ end
146
+
147
+ # Response trailing metadata (after the call ends).
148
+ def trailers
149
+ @stream.trailers
150
+ end
151
+
152
+ def cancel
153
+ @stream.cancel
154
+ end
155
+
156
+ def close
157
+ @stream.cancel
158
+ end
159
+
160
+ def each
161
+ return enum_for(:each) unless block_given?
162
+
163
+ begin
164
+ loop do
165
+ begin
166
+ yield next_msg
167
+ rescue StopIteration
168
+ return
169
+ end
170
+ end
171
+ ensure
172
+ # Breaking out of the block abandons the call: RST so
173
+ # the server stops producing (no-op once terminated).
174
+ close
175
+ end
176
+ end
177
+ end
178
+
179
+ class EventBusClient
180
+ def initialize(channel)
181
+ @channel = channel
182
+ end
183
+
184
+ def Publish(req, metadata = nil, timeout: nil)
185
+ @channel.unary("/grpcdc.events.v1.EventBus/Publish", req, EventsPb::PublishReply.new, metadata, timeout: timeout)
186
+ end
187
+
188
+ def Subscribe(req, metadata = nil, timeout: nil)
189
+ stream = @channel.server_stream("/grpcdc.events.v1.EventBus/Subscribe", req, metadata, timeout: timeout)
190
+ RecvStream.new(stream, EventsPb::Event)
191
+ end
192
+
193
+ end
194
+
195
+ # Fiber client: wraps a Grpcdc::FiberChannel (a sync Channel is wrapped).
196
+ class EventBusClientFiber
197
+ def initialize(channel)
198
+ @channel = channel.is_a?(Grpcdc::FiberChannel) ? channel : Grpcdc::FiberChannel.new(channel)
199
+ end
200
+
201
+ def Publish(req, metadata = nil, timeout: nil)
202
+ @channel.unary("/grpcdc.events.v1.EventBus/Publish", req, EventsPb::PublishReply.new, metadata, timeout: timeout)
203
+ end
204
+
205
+ def Subscribe(req, metadata = nil, timeout: nil)
206
+ stream = @channel.server_stream("/grpcdc.events.v1.EventBus/Subscribe", req, metadata, timeout: timeout)
207
+ FiberRecvStream.new(stream, EventsPb::Event)
208
+ end
209
+
210
+ end
211
+
212
+ def self.register_event_bus_server(server, impl)
213
+ publish_handler = lambda do |ctx, reqs, sink|
214
+ req = reqs.recv_into(EventsPb::PublishRequest.new)
215
+ resp = impl.Publish(ctx, req)
216
+ sink.send(resp.marshal_dc)
217
+ end
218
+
219
+ subscribe_handler = lambda do |ctx, reqs, sink|
220
+ req = reqs.recv_into(EventsPb::SubscribeRequest.new)
221
+ impl.Subscribe(req, SendStream.new(ctx, sink))
222
+ end
223
+
224
+ server.register_service(Grpcdc::ServiceDesc.new(
225
+ "grpcdc.events.v1.EventBus",
226
+ [
227
+ Grpcdc::Method.new("Publish", "/grpcdc.events.v1.EventBus/Publish", Grpcdc::KIND_UNARY, publish_handler),
228
+ Grpcdc::Method.new("Subscribe", "/grpcdc.events.v1.EventBus/Subscribe", Grpcdc::KIND_SERVER_STREAMING, subscribe_handler),
229
+ ]
230
+ ))
231
+ end
232
+ end
@@ -0,0 +1,432 @@
1
+ # Generated code: use without restriction (see GENERATED-CODE-LICENSE.md).
2
+ module EventsPb
3
+ # @generated by protoc-gen-grpc-dc-ruby. DO NOT EDIT.
4
+ EventsPbVarint = lambda do |value|
5
+ out = +"".b
6
+ v = value & 0xffffffffffffffff
7
+ while v > 0x7f
8
+ out << ((v & 0x7f) | 0x80)
9
+ v >>= 7
10
+ end
11
+ out << v
12
+ out
13
+ end
14
+
15
+ class Writer
16
+ def initialize
17
+ @out = String.new(encoding: Encoding::BINARY)
18
+ end
19
+
20
+ def varint(value)
21
+ @out << EventsPbVarint.call(value)
22
+ end
23
+
24
+ def tag(field, wire)
25
+ varint((field << 3) | wire)
26
+ end
27
+
28
+ def bytes_field(field, payload)
29
+ tag(field, 2)
30
+ varint(payload.bytesize)
31
+ @out << payload.b
32
+ end
33
+
34
+ def string_field(field, value)
35
+ return if value.nil? || value.empty?
36
+
37
+ bytes_field(field, value.encode(Encoding::UTF_8).b)
38
+ end
39
+
40
+ def fixed(fmt, value)
41
+ @out << [value].pack(fmt)
42
+ end
43
+
44
+ def raw(payload)
45
+ @out << payload.b
46
+ end
47
+
48
+ def to_bytes
49
+ @out
50
+ end
51
+ end
52
+
53
+ class Reader
54
+ def initialize(buf)
55
+ @buf = buf.b
56
+ @pos = 0
57
+ end
58
+
59
+ def done?
60
+ @pos >= @buf.bytesize
61
+ end
62
+
63
+ def varint
64
+ result = 0
65
+ shift = 0
66
+ loop do
67
+ raise ArgumentError, "truncated varint" if @pos >= @buf.bytesize
68
+
69
+ b = @buf.getbyte(@pos)
70
+ @pos += 1
71
+ result |= (b & 0x7f) << shift
72
+ return result if (b & 0x80).zero?
73
+
74
+ shift += 7
75
+ raise ArgumentError, "varint too long" if shift >= 70
76
+ end
77
+ end
78
+
79
+ def take(n)
80
+ raise ArgumentError, "truncated field" if @pos + n > @buf.bytesize
81
+
82
+ value = @buf.byteslice(@pos, n)
83
+ @pos += n
84
+ value
85
+ end
86
+
87
+ # [number, wire, varint_value, bytes_value, fixed_value] or nil.
88
+ def field
89
+ return nil if done?
90
+
91
+ start = @pos
92
+ tag = varint
93
+ num = tag >> 3
94
+ wire = tag & 7
95
+ raw = -> { @buf.byteslice(start, @pos - start) }
96
+ case wire
97
+ when 0 then [num, wire, varint, "".b, "".b, raw.call]
98
+ when 2
99
+ n = varint
100
+ v = take(n)
101
+ [num, wire, 0, v, "".b, raw.call]
102
+ when 1
103
+ v = take(8)
104
+ [num, wire, 0, "".b, v, raw.call]
105
+ when 5
106
+ v = take(4)
107
+ [num, wire, 0, "".b, v, raw.call]
108
+ else raise ArgumentError, "bad wire type"
109
+ end
110
+ end
111
+ end
112
+
113
+ module Tag
114
+ TAG_UNSPECIFIED = 0
115
+ TOPIC = 1
116
+ SOURCE = 2
117
+ KIND = 3
118
+ end
119
+
120
+ class TagValue
121
+ attr_accessor :tag, :string_value, :int_value, :double_value, :bool_value, :enum_value, :unknown_fields
122
+
123
+ def initialize(tag: 0, string_value: "", int_value: 0, double_value: 0.0, bool_value: false, enum_value: 0)
124
+ @tag = tag
125
+ @string_value = string_value
126
+ @int_value = int_value
127
+ @double_value = double_value
128
+ @bool_value = bool_value
129
+ @enum_value = enum_value
130
+ @unknown_fields = "".b
131
+ end
132
+
133
+ def marshal_dc
134
+ w = Writer.new
135
+ if @tag != 0
136
+ w.tag(1, 0)
137
+ w.varint(@tag)
138
+ end
139
+ unless (@int_value != 0 || @double_value != 0 || @bool_value || @enum_value != 0)
140
+ w.string_field(2, @string_value)
141
+ end
142
+ unless (@double_value != 0 || @bool_value || @enum_value != 0)
143
+ if @int_value != 0
144
+ w.tag(3, 0)
145
+ w.varint(@int_value)
146
+ end
147
+ end
148
+ unless (@bool_value || @enum_value != 0)
149
+ if @double_value != 0
150
+ w.tag(4, 1)
151
+ w.fixed("E", @double_value)
152
+ end
153
+ end
154
+ unless (@enum_value != 0)
155
+ if @bool_value
156
+ w.tag(5, 0)
157
+ w.varint((@bool_value ? 1 : 0))
158
+ end
159
+ end
160
+ if @enum_value != 0
161
+ w.tag(6, 0)
162
+ w.varint(@enum_value)
163
+ end
164
+ w.raw(@unknown_fields)
165
+ w.to_bytes
166
+ end
167
+
168
+ def unmarshal_dc(data)
169
+ @unknown_fields = "".b
170
+ @tag = 0
171
+ @string_value = ""
172
+ @int_value = 0
173
+ @double_value = 0.0
174
+ @bool_value = false
175
+ @enum_value = 0
176
+ r = Reader.new(data)
177
+ loop do
178
+ item = r.field
179
+ break if item.nil?
180
+
181
+ num, wire, varint_value, bytes_value, fixed_value, raw_value = item
182
+ case num
183
+ when 1
184
+ @tag = (((varint_value & 0xffffffff) ^ 0x80000000) - 0x80000000)
185
+ when 2
186
+ @int_value = 0
187
+ @double_value = 0.0
188
+ @bool_value = false
189
+ @enum_value = 0
190
+ @string_value = bytes_value.dup.force_encoding(Encoding::UTF_8)
191
+ when 3
192
+ @string_value = ""
193
+ @double_value = 0.0
194
+ @bool_value = false
195
+ @enum_value = 0
196
+ @int_value = (((varint_value & 0xffffffffffffffff) ^ 0x8000000000000000) - 0x8000000000000000)
197
+ when 4
198
+ @string_value = ""
199
+ @int_value = 0
200
+ @bool_value = false
201
+ @enum_value = 0
202
+ @double_value = fixed_value.unpack1("E")
203
+ when 5
204
+ @string_value = ""
205
+ @int_value = 0
206
+ @double_value = 0.0
207
+ @enum_value = 0
208
+ @bool_value = (varint_value != 0)
209
+ when 6
210
+ @string_value = ""
211
+ @int_value = 0
212
+ @double_value = 0.0
213
+ @bool_value = false
214
+ @enum_value = (((varint_value & 0xffffffff) ^ 0x80000000) - 0x80000000)
215
+ else
216
+ @unknown_fields = @unknown_fields + raw_value
217
+ end
218
+ end
219
+ self
220
+ end
221
+
222
+ def ==(other)
223
+ other.is_a?(TagValue) && @tag == other.tag && @string_value == other.string_value && @int_value == other.int_value && @double_value == other.double_value && @bool_value == other.bool_value && @enum_value == other.enum_value
224
+ end
225
+ end
226
+
227
+ class PublishRequest
228
+ attr_accessor :tags, :payload, :publisher_id, :unknown_fields
229
+
230
+ def initialize(tags: [], payload: "".b, publisher_id: "")
231
+ @tags = tags
232
+ @payload = payload
233
+ @publisher_id = publisher_id
234
+ @unknown_fields = "".b
235
+ end
236
+
237
+ def marshal_dc
238
+ w = Writer.new
239
+ @tags.each { |x| w.bytes_field(1, x.marshal_dc) }
240
+ if @payload.bytesize > 0
241
+ w.bytes_field(2, @payload)
242
+ end
243
+ w.string_field(3, @publisher_id)
244
+ w.raw(@unknown_fields)
245
+ w.to_bytes
246
+ end
247
+
248
+ def unmarshal_dc(data)
249
+ @unknown_fields = "".b
250
+ @tags = []
251
+ @payload = "".b
252
+ @publisher_id = ""
253
+ r = Reader.new(data)
254
+ loop do
255
+ item = r.field
256
+ break if item.nil?
257
+
258
+ num, wire, varint_value, bytes_value, fixed_value, raw_value = item
259
+ case num
260
+ when 1
261
+ item = TagValue.new
262
+ item.unmarshal_dc(bytes_value)
263
+ @tags << item
264
+ when 2
265
+ @payload = bytes_value
266
+ when 3
267
+ @publisher_id = bytes_value.dup.force_encoding(Encoding::UTF_8)
268
+ else
269
+ @unknown_fields = @unknown_fields + raw_value
270
+ end
271
+ end
272
+ self
273
+ end
274
+
275
+ def ==(other)
276
+ other.is_a?(PublishRequest) && @tags == other.tags && @payload == other.payload && @publisher_id == other.publisher_id
277
+ end
278
+ end
279
+
280
+ class PublishReply
281
+ attr_accessor :seq, :unknown_fields
282
+
283
+ def initialize(seq: 0)
284
+ @seq = seq
285
+ @unknown_fields = "".b
286
+ end
287
+
288
+ def marshal_dc
289
+ w = Writer.new
290
+ if @seq != 0
291
+ w.tag(1, 0)
292
+ w.varint(@seq)
293
+ end
294
+ w.raw(@unknown_fields)
295
+ w.to_bytes
296
+ end
297
+
298
+ def unmarshal_dc(data)
299
+ @unknown_fields = "".b
300
+ @seq = 0
301
+ r = Reader.new(data)
302
+ loop do
303
+ item = r.field
304
+ break if item.nil?
305
+
306
+ num, wire, varint_value, bytes_value, fixed_value, raw_value = item
307
+ case num
308
+ when 1
309
+ @seq = (varint_value & 0xffffffffffffffff)
310
+ else
311
+ @unknown_fields = @unknown_fields + raw_value
312
+ end
313
+ end
314
+ self
315
+ end
316
+
317
+ def ==(other)
318
+ other.is_a?(PublishReply) && @seq == other.seq
319
+ end
320
+ end
321
+
322
+ class SubscribeRequest
323
+ attr_accessor :filter, :unknown_fields
324
+
325
+ def initialize(filter: [])
326
+ @filter = filter
327
+ @unknown_fields = "".b
328
+ end
329
+
330
+ def marshal_dc
331
+ w = Writer.new
332
+ @filter.each { |x| w.bytes_field(1, x.marshal_dc) }
333
+ w.raw(@unknown_fields)
334
+ w.to_bytes
335
+ end
336
+
337
+ def unmarshal_dc(data)
338
+ @unknown_fields = "".b
339
+ @filter = []
340
+ r = Reader.new(data)
341
+ loop do
342
+ item = r.field
343
+ break if item.nil?
344
+
345
+ num, wire, varint_value, bytes_value, fixed_value, raw_value = item
346
+ case num
347
+ when 1
348
+ item = TagValue.new
349
+ item.unmarshal_dc(bytes_value)
350
+ @filter << item
351
+ else
352
+ @unknown_fields = @unknown_fields + raw_value
353
+ end
354
+ end
355
+ self
356
+ end
357
+
358
+ def ==(other)
359
+ other.is_a?(SubscribeRequest) && @filter == other.filter
360
+ end
361
+ end
362
+
363
+ class Event
364
+ attr_accessor :tags, :payload, :seq, :publisher_id, :timestamp_unix_ms, :unknown_fields
365
+
366
+ def initialize(tags: [], payload: "".b, seq: 0, publisher_id: "", timestamp_unix_ms: 0)
367
+ @tags = tags
368
+ @payload = payload
369
+ @seq = seq
370
+ @publisher_id = publisher_id
371
+ @timestamp_unix_ms = timestamp_unix_ms
372
+ @unknown_fields = "".b
373
+ end
374
+
375
+ def marshal_dc
376
+ w = Writer.new
377
+ @tags.each { |x| w.bytes_field(1, x.marshal_dc) }
378
+ if @payload.bytesize > 0
379
+ w.bytes_field(2, @payload)
380
+ end
381
+ if @seq != 0
382
+ w.tag(3, 0)
383
+ w.varint(@seq)
384
+ end
385
+ w.string_field(4, @publisher_id)
386
+ if @timestamp_unix_ms != 0
387
+ w.tag(5, 0)
388
+ w.varint(@timestamp_unix_ms)
389
+ end
390
+ w.raw(@unknown_fields)
391
+ w.to_bytes
392
+ end
393
+
394
+ def unmarshal_dc(data)
395
+ @unknown_fields = "".b
396
+ @tags = []
397
+ @payload = "".b
398
+ @seq = 0
399
+ @publisher_id = ""
400
+ @timestamp_unix_ms = 0
401
+ r = Reader.new(data)
402
+ loop do
403
+ item = r.field
404
+ break if item.nil?
405
+
406
+ num, wire, varint_value, bytes_value, fixed_value, raw_value = item
407
+ case num
408
+ when 1
409
+ item = TagValue.new
410
+ item.unmarshal_dc(bytes_value)
411
+ @tags << item
412
+ when 2
413
+ @payload = bytes_value
414
+ when 3
415
+ @seq = (varint_value & 0xffffffffffffffff)
416
+ when 4
417
+ @publisher_id = bytes_value.dup.force_encoding(Encoding::UTF_8)
418
+ when 5
419
+ @timestamp_unix_ms = (((varint_value & 0xffffffffffffffff) ^ 0x8000000000000000) - 0x8000000000000000)
420
+ else
421
+ @unknown_fields = @unknown_fields + raw_value
422
+ end
423
+ end
424
+ self
425
+ end
426
+
427
+ def ==(other)
428
+ other.is_a?(Event) && @tags == other.tags && @payload == other.payload && @seq == other.seq && @publisher_id == other.publisher_id && @timestamp_unix_ms == other.timestamp_unix_ms
429
+ end
430
+ end
431
+
432
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eventbus-grpc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.38.0
5
+ platform: ruby
6
+ authors:
7
+ - John Davis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-11-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: grpc-dc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.38.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.38.0
27
+ description: Event bus over gRPC — generated grpcdc.events.v1 publish/subscribe clients
28
+ over WebRTC DataChannels, via the grpc-dc runtime (Ruby).
29
+ email:
30
+ - jdavis@pcprogramming.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE
36
+ - README.md
37
+ - lib/eventbus_grpc.rb
38
+ - lib/grpcdc/events_grpc_dc.rb
39
+ - lib/grpcdc/events_pb.rb
40
+ homepage: https://github.com/browser-grpc/grpc-over-datachannels
41
+ licenses:
42
+ - Apache-2.0
43
+ metadata:
44
+ homepage_uri: https://github.com/browser-grpc/grpc-over-datachannels
45
+ source_code_uri: https://github.com/browser-grpc/grpc-over-datachannels/tree/main/packages/eventbus-ruby
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.3.15
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Event bus over gRPC — generated grpcdc.events.v1 Ruby clients
65
+ test_files: []