felix-client 0.5.0__tar.gz

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.
Files changed (103) hide show
  1. felix_client-0.5.0/LICENSE +201 -0
  2. felix_client-0.5.0/PKG-INFO +127 -0
  3. felix_client-0.5.0/README.md +89 -0
  4. felix_client-0.5.0/felix-client/Cargo.toml +62 -0
  5. felix_client-0.5.0/felix-client/LICENSE +201 -0
  6. felix_client-0.5.0/felix-client/README.md +63 -0
  7. felix_client-0.5.0/felix-client/src/client/cache.rs +307 -0
  8. felix_client-0.5.0/felix-client/src/client/cache_watch.rs +173 -0
  9. felix_client-0.5.0/felix-client/src/client/client.rs +1661 -0
  10. felix_client-0.5.0/felix-client/src/client/cluster.rs +924 -0
  11. felix_client-0.5.0/felix-client/src/client/event_router.rs +268 -0
  12. felix_client-0.5.0/felix-client/src/client/idempotent.rs +394 -0
  13. felix_client-0.5.0/felix-client/src/client/inprocess.rs +75 -0
  14. felix_client-0.5.0/felix-client/src/client/publisher.rs +2606 -0
  15. felix_client-0.5.0/felix-client/src/client/sharded.rs +332 -0
  16. felix_client-0.5.0/felix-client/src/client/sharding.rs +75 -0
  17. felix_client-0.5.0/felix-client/src/client/subscription.rs +514 -0
  18. felix_client-0.5.0/felix-client/src/client/subscription_tests.rs +96 -0
  19. felix_client-0.5.0/felix-client/src/client.rs +14 -0
  20. felix_client-0.5.0/felix-client/src/config.rs +497 -0
  21. felix_client-0.5.0/felix-client/src/counters.rs +226 -0
  22. felix_client-0.5.0/felix-client/src/lib.rs +119 -0
  23. felix_client-0.5.0/felix-client/src/macros.rs +155 -0
  24. felix_client-0.5.0/felix-client/src/tests.rs +1914 -0
  25. felix_client-0.5.0/felix-client/src/timings.rs +154 -0
  26. felix_client-0.5.0/felix-client/src/timings_telemetry.rs +599 -0
  27. felix_client-0.5.0/felix-client/src/wire/ack.rs +401 -0
  28. felix_client-0.5.0/felix-client/src/wire/bench_ts.rs +142 -0
  29. felix_client-0.5.0/felix-client/src/wire/decode_log.rs +96 -0
  30. felix_client-0.5.0/felix-client/src/wire/frame_io.rs +217 -0
  31. felix_client-0.5.0/felix-client/src/wire.rs +17 -0
  32. felix_client-0.5.0/felix-python/Cargo.lock +1388 -0
  33. felix_client-0.5.0/felix-python/Cargo.toml +39 -0
  34. felix_client-0.5.0/felix-python/LICENSE +201 -0
  35. felix_client-0.5.0/felix-python/README.md +89 -0
  36. felix_client-0.5.0/felix-python/src/asyncio.rs +988 -0
  37. felix_client-0.5.0/felix-python/src/errors.rs +92 -0
  38. felix_client-0.5.0/felix-python/src/lib.rs +1071 -0
  39. felix_client-0.5.0/felix-python/src/runtime.rs +42 -0
  40. felix_client-0.5.0/felix-python/src/tls.rs +53 -0
  41. felix_client-0.5.0/felix-python/src/types.rs +345 -0
  42. felix_client-0.5.0/felix-python/tests/conftest.py +209 -0
  43. felix_client-0.5.0/felix-python/tests/test_cache.py +276 -0
  44. felix_client-0.5.0/felix-python/tests/test_cluster.py +209 -0
  45. felix_client-0.5.0/felix-python/tests/test_errors.py +161 -0
  46. felix_client-0.5.0/felix-python/tests/test_pubsub.py +206 -0
  47. felix_client-0.5.0/felix-python/tests/test_queues.py +215 -0
  48. felix_client-0.5.0/felix-python/tests/test_retry.py +74 -0
  49. felix_client-0.5.0/felix-python/tests/test_sharded.py +178 -0
  50. felix_client-0.5.0/felix-transport/Cargo.toml +36 -0
  51. felix_client-0.5.0/felix-transport/LICENSE +201 -0
  52. felix_client-0.5.0/felix-transport/README.md +24 -0
  53. felix_client-0.5.0/felix-transport/src/lib.rs +1524 -0
  54. felix_client-0.5.0/felix-wire/Cargo.toml +30 -0
  55. felix_client-0.5.0/felix-wire/LICENSE +201 -0
  56. felix_client-0.5.0/felix-wire/README.md +26 -0
  57. felix_client-0.5.0/felix-wire/src/base64_serde.rs +137 -0
  58. felix_client-0.5.0/felix-wire/src/binary.rs +908 -0
  59. felix_client-0.5.0/felix-wire/src/error.rs +31 -0
  60. felix_client-0.5.0/felix-wire/src/frame.rs +345 -0
  61. felix_client-0.5.0/felix-wire/src/internal.rs +1243 -0
  62. felix_client-0.5.0/felix-wire/src/internal_tests.rs +899 -0
  63. felix_client-0.5.0/felix-wire/src/lib.rs +43 -0
  64. felix_client-0.5.0/felix-wire/src/message.rs +725 -0
  65. felix_client-0.5.0/felix-wire/src/tests.rs +1838 -0
  66. felix_client-0.5.0/felix-wire/src/text.rs +254 -0
  67. felix_client-0.5.0/felix-wire/tests/vectors/README.md +41 -0
  68. felix_client-0.5.0/felix-wire/tests/vectors/auth_ok.hex +1 -0
  69. felix_client-0.5.0/felix-wire/tests/vectors/auth_ok.json +7 -0
  70. felix_client-0.5.0/felix-wire/tests/vectors/auth_with_capabilities.hex +1 -0
  71. felix_client-0.5.0/felix-wire/tests/vectors/auth_with_capabilities.json +7 -0
  72. felix_client-0.5.0/felix-wire/tests/vectors/binary_publish_ack_error.hex +1 -0
  73. felix_client-0.5.0/felix-wire/tests/vectors/binary_publish_ack_error.json +10 -0
  74. felix_client-0.5.0/felix-wire/tests/vectors/binary_publish_ack_ok.hex +1 -0
  75. felix_client-0.5.0/felix-wire/tests/vectors/binary_publish_ack_ok.json +10 -0
  76. felix_client-0.5.0/felix-wire/tests/vectors/binary_publish_acked.hex +1 -0
  77. felix_client-0.5.0/felix-wire/tests/vectors/binary_publish_acked.json +15 -0
  78. felix_client-0.5.0/felix-wire/tests/vectors/binary_publish_acked_keyed.hex +1 -0
  79. felix_client-0.5.0/felix-wire/tests/vectors/binary_publish_acked_keyed.json +16 -0
  80. felix_client-0.5.0/felix-wire/tests/vectors/binary_publish_keyed.hex +1 -0
  81. felix_client-0.5.0/felix-wire/tests/vectors/binary_publish_keyed.json +14 -0
  82. felix_client-0.5.0/felix-wire/tests/vectors/cache_get.hex +1 -0
  83. felix_client-0.5.0/felix-wire/tests/vectors/cache_get.json +6 -0
  84. felix_client-0.5.0/felix-wire/tests/vectors/cache_put.hex +1 -0
  85. felix_client-0.5.0/felix-wire/tests/vectors/cache_put.json +6 -0
  86. felix_client-0.5.0/felix-wire/tests/vectors/cache_value.hex +1 -0
  87. felix_client-0.5.0/felix-wire/tests/vectors/cache_value.json +6 -0
  88. felix_client-0.5.0/felix-wire/tests/vectors/error.hex +1 -0
  89. felix_client-0.5.0/felix-wire/tests/vectors/error.json +6 -0
  90. felix_client-0.5.0/felix-wire/tests/vectors/event.hex +1 -0
  91. felix_client-0.5.0/felix-wire/tests/vectors/event.json +6 -0
  92. felix_client-0.5.0/felix-wire/tests/vectors/ok.hex +1 -0
  93. felix_client-0.5.0/felix-wire/tests/vectors/ok.json +6 -0
  94. felix_client-0.5.0/felix-wire/tests/vectors/publish.hex +1 -0
  95. felix_client-0.5.0/felix-wire/tests/vectors/publish.json +6 -0
  96. felix_client-0.5.0/felix-wire/tests/vectors/subscribe.hex +1 -0
  97. felix_client-0.5.0/felix-wire/tests/vectors/subscribe.json +6 -0
  98. felix_client-0.5.0/felix-wire/tests/vectors.rs +176 -0
  99. felix_client-0.5.0/felix-wire/tests/wire_fuzz.rs +316 -0
  100. felix_client-0.5.0/pyproject.toml +57 -0
  101. felix_client-0.5.0/python/felix/__init__.py +97 -0
  102. felix_client-0.5.0/python/felix/_felix.pyi +379 -0
  103. felix_client-0.5.0/python/felix/py.typed +0 -0
@@ -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 [yyyy] [name of copyright owner]
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.
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: felix-client
3
+ Version: 0.5.0
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: License :: OSI Approved :: Apache Software License
7
+ Classifier: Operating System :: MacOS
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Classifier: Operating System :: POSIX :: Linux
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: Implementation :: CPython
17
+ Classifier: Programming Language :: Rust
18
+ Classifier: Topic :: Database
19
+ Classifier: Topic :: System :: Distributed Computing
20
+ Classifier: Topic :: System :: Networking
21
+ Classifier: Typing :: Typed
22
+ Requires-Dist: pytest>=8 ; extra == 'test'
23
+ Provides-Extra: test
24
+ License-File: LICENSE
25
+ Summary: Python client for Felix — streams, queues, and cache over QUIC
26
+ Keywords: felix,quic,pubsub,streaming,cache
27
+ Home-Page: https://github.com/gabloe/felix
28
+ Author: Gabriel Loewen
29
+ License: Apache-2.0
30
+ Requires-Python: >=3.9
31
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
32
+ Project-URL: Changelog, https://github.com/gabloe/felix/blob/main/CHANGELOG.md
33
+ Project-URL: Documentation, https://gabloe.github.io/felix/clients/python/
34
+ Project-URL: Homepage, https://gabloe.github.io/felix/
35
+ Project-URL: Issues, https://github.com/gabloe/felix/issues
36
+ Project-URL: Repository, https://github.com/gabloe/felix
37
+
38
+ # felix-client for Python
39
+
40
+ Python bindings for Felix, built as a wrapper over the Rust client rather than
41
+ a reimplementation of the protocol.
42
+
43
+ That distinction is the point. Reconnection, redirect-following, retry
44
+ classification and offset bookkeeping are hard to get right and expensive to
45
+ get wrong — a second implementation is a second set of subtle bugs in exactly
46
+ the places that matter. Here they exist once, in `felix-client`, and every
47
+ language binds to them.
48
+
49
+ ## Two surfaces
50
+
51
+ Synchronous, for threads and `asyncio.to_thread`:
52
+
53
+ ```python
54
+ import felix
55
+
56
+ with felix.Client("127.0.0.1:5000", tenant_id="t1", token=tok, ca_file=ca) as client:
57
+ client.publish("t1", "default", "events", b"hello")
58
+ with client.subscribe("t1", "default", "events") as events:
59
+ for event in events:
60
+ print(event.payload, event.offset)
61
+ ```
62
+
63
+ Asynchronous, which is what most Python realtime backends want:
64
+
65
+ ```python
66
+ client = await felix.AsyncClient.connect(addr, tenant_id="t1", token=tok, ca_file=ca)
67
+ async with client:
68
+ await client.publish("t1", "default", "events", b"hello")
69
+ async with await client.subscribe("t1", "default", "events") as events:
70
+ async for event in events:
71
+ print(event.payload, event.offset)
72
+ ```
73
+
74
+ Both wrap the same client and fail over identically. The sync one blocks with
75
+ the GIL released; the async one yields to your event loop.
76
+
77
+ ## Beyond publish and subscribe
78
+
79
+ Both surfaces also cover consumer groups (`group_poll` and the four settles),
80
+ cache watches (`watch_cache`, including retained watches that hand you current
81
+ state before live changes), and multi-shard subscriptions (`subscribe_sharded`,
82
+ which opens one subscription per shard and merges them). Two things catch
83
+ people out, so they are worth saying here:
84
+
85
+ - **Publishing without a `key=` puts every record on shard 0.** The key is what
86
+ spreads a stream, and a multi-shard stream published without one behaves
87
+ exactly like a single-shard one.
88
+ - **A prefix watch reads one shard.** Keys sharing a prefix do not share a
89
+ shard, so watching a whole multi-shard cache means one watch per shard.
90
+
91
+ The [clients page](../../docs-site/src/content/docs/api/clients.md) has the
92
+ worked examples.
93
+
94
+ ## TLS
95
+
96
+ QUIC has no unencrypted mode, so there is always a trust decision — and
97
+ deliberately no "skip verification" switch, because that is the setting that
98
+ silently turns a secure deployment insecure. Either the platform trust store
99
+ (the default) or an explicit CA:
100
+
101
+ ```python
102
+ felix.Client(addr, tenant_id=..., token=..., ca_file="/path/to/ca.pem")
103
+ ```
104
+
105
+ A development broker generates a self-signed certificate at startup; set
106
+ `FELIX_TLS_CERT_EXPORT=/path/ca.pem` on the broker and point `ca_file` at it.
107
+
108
+ ## Building
109
+
110
+ ```bash
111
+ pip install maturin
112
+ task python:develop # build and install into the active virtualenv
113
+ task python:check # fmt, clippy, build
114
+ ```
115
+
116
+ This crate is deliberately outside the Cargo workspace — an extension module
117
+ carries `pyo3/extension-module`, which cannot be linked into a test binary —
118
+ so `task python:check` is what builds it, not `task test`.
119
+
120
+ ## Conformance
121
+
122
+ The semantics a Felix client must implement are catalogued in
123
+ `crates/felix-conformance/scenarios.toml`, with `task conformance:scenarios`
124
+ to read them and `task conformance:verify` to check a client's results. That
125
+ catalogue — not this README — is the contract, and it is what the next
126
+ language's client is gated on.
127
+
@@ -0,0 +1,89 @@
1
+ # felix-client for Python
2
+
3
+ Python bindings for Felix, built as a wrapper over the Rust client rather than
4
+ a reimplementation of the protocol.
5
+
6
+ That distinction is the point. Reconnection, redirect-following, retry
7
+ classification and offset bookkeeping are hard to get right and expensive to
8
+ get wrong — a second implementation is a second set of subtle bugs in exactly
9
+ the places that matter. Here they exist once, in `felix-client`, and every
10
+ language binds to them.
11
+
12
+ ## Two surfaces
13
+
14
+ Synchronous, for threads and `asyncio.to_thread`:
15
+
16
+ ```python
17
+ import felix
18
+
19
+ with felix.Client("127.0.0.1:5000", tenant_id="t1", token=tok, ca_file=ca) as client:
20
+ client.publish("t1", "default", "events", b"hello")
21
+ with client.subscribe("t1", "default", "events") as events:
22
+ for event in events:
23
+ print(event.payload, event.offset)
24
+ ```
25
+
26
+ Asynchronous, which is what most Python realtime backends want:
27
+
28
+ ```python
29
+ client = await felix.AsyncClient.connect(addr, tenant_id="t1", token=tok, ca_file=ca)
30
+ async with client:
31
+ await client.publish("t1", "default", "events", b"hello")
32
+ async with await client.subscribe("t1", "default", "events") as events:
33
+ async for event in events:
34
+ print(event.payload, event.offset)
35
+ ```
36
+
37
+ Both wrap the same client and fail over identically. The sync one blocks with
38
+ the GIL released; the async one yields to your event loop.
39
+
40
+ ## Beyond publish and subscribe
41
+
42
+ Both surfaces also cover consumer groups (`group_poll` and the four settles),
43
+ cache watches (`watch_cache`, including retained watches that hand you current
44
+ state before live changes), and multi-shard subscriptions (`subscribe_sharded`,
45
+ which opens one subscription per shard and merges them). Two things catch
46
+ people out, so they are worth saying here:
47
+
48
+ - **Publishing without a `key=` puts every record on shard 0.** The key is what
49
+ spreads a stream, and a multi-shard stream published without one behaves
50
+ exactly like a single-shard one.
51
+ - **A prefix watch reads one shard.** Keys sharing a prefix do not share a
52
+ shard, so watching a whole multi-shard cache means one watch per shard.
53
+
54
+ The [clients page](../../docs-site/src/content/docs/api/clients.md) has the
55
+ worked examples.
56
+
57
+ ## TLS
58
+
59
+ QUIC has no unencrypted mode, so there is always a trust decision — and
60
+ deliberately no "skip verification" switch, because that is the setting that
61
+ silently turns a secure deployment insecure. Either the platform trust store
62
+ (the default) or an explicit CA:
63
+
64
+ ```python
65
+ felix.Client(addr, tenant_id=..., token=..., ca_file="/path/to/ca.pem")
66
+ ```
67
+
68
+ A development broker generates a self-signed certificate at startup; set
69
+ `FELIX_TLS_CERT_EXPORT=/path/ca.pem` on the broker and point `ca_file` at it.
70
+
71
+ ## Building
72
+
73
+ ```bash
74
+ pip install maturin
75
+ task python:develop # build and install into the active virtualenv
76
+ task python:check # fmt, clippy, build
77
+ ```
78
+
79
+ This crate is deliberately outside the Cargo workspace — an extension module
80
+ carries `pyo3/extension-module`, which cannot be linked into a test binary —
81
+ so `task python:check` is what builds it, not `task test`.
82
+
83
+ ## Conformance
84
+
85
+ The semantics a Felix client must implement are catalogued in
86
+ `crates/felix-conformance/scenarios.toml`, with `task conformance:scenarios`
87
+ to read them and `task conformance:verify` to check a client's results. That
88
+ catalogue — not this README — is the contract, and it is what the next
89
+ language's client is gated on.
@@ -0,0 +1,62 @@
1
+ [package]
2
+ name = "felix-client"
3
+ version = "0.5.0"
4
+ edition = "2024"
5
+ license = "Apache-2.0"
6
+ rust-version = "1.97.0"
7
+ description = "Rust client SDK for the Felix pub/sub and cache broker"
8
+ repository = "https://github.com/gabloe/felix"
9
+ homepage = "https://github.com/gabloe/felix"
10
+ readme = "README.md"
11
+ keywords = ["felix", "client", "pubsub", "messaging", "quic"]
12
+ categories = ["network-programming", "api-bindings"]
13
+
14
+ [dependencies]
15
+ thiserror = "^2"
16
+ anyhow = "^1"
17
+ bytes = "^1"
18
+ ahash = "^0.8"
19
+ hashbrown = { version = "^0.17", features = ["equivalent"] }
20
+ tokio = { version = "^1", features = ["rt-multi-thread", "macros", "net", "time", "sync", "signal", "test-util"] }
21
+ tracing = "^0.1"
22
+ metrics = "^0.24"
23
+ serde = { version = "^1", features = ["derive"] }
24
+ serde_yaml_ng = "^0.10"
25
+ # felix-broker/felix-storage are optional: they're only needed by the `in-process` feature
26
+ # (an embedded-broker convenience mode for local dev/tests). Both are AGPL-3.0 licensed,
27
+ # unlike the rest of this crate's dependency graph (Apache-2.0) — keeping them optional and
28
+ # off by default means the default felix-client build has zero AGPL-3.0 transitive
29
+ # dependencies. See LICENSING.md at the repo root.
30
+ felix-broker = { path = "../felix-broker", version = "0.5.0", optional = true }
31
+ felix-storage = { path = "../felix-storage", version = "0.5.0", optional = true }
32
+ felix-transport = { path = "../felix-transport", version = "0.5.0" }
33
+ felix-wire = { path = "../felix-wire", version = "0.5.0" }
34
+ quinn = "^0.11"
35
+
36
+ [features]
37
+ default = []
38
+ telemetry = []
39
+ # Embedded-broker convenience mode for local dev/tests, without a real QUIC connection.
40
+ # Off by default — see the dependency comment above.
41
+ in-process = ["dep:felix-broker", "dep:felix-storage"]
42
+
43
+ [dev-dependencies]
44
+ rcgen = "^0.14"
45
+ rustls = "^0.23"
46
+ serial_test = "^4"
47
+ tempfile = "^3"
48
+ tracing-subscriber = { version = "^0.3", features = ["env-filter"] }
49
+
50
+ [package.metadata.docs.rs]
51
+ # `in-process` and `telemetry` are off by default; document them anyway.
52
+ all-features = true
53
+
54
+ [lints.rust]
55
+ # `pub` that is not actually reachable from outside the crate reads as public
56
+ # API and makes the real surface hard to see. Use `pub(crate)`.
57
+ unreachable_pub = "warn"
58
+
59
+ [lints.clippy]
60
+ # One module style: `foo.rs` + `foo/`, never `foo/mod.rs`. `task lint` runs
61
+ # clippy with -D warnings, so this fails CI on a new mod.rs.
62
+ mod_module_files = "warn"