neonlink-client 1.3.25__py3-none-any.whl
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.
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: neonlink-client
|
|
3
|
+
Version: 1.3.25
|
|
4
|
+
Summary: Official Python client for NeonLink message broker
|
|
5
|
+
Project-URL: Homepage, https://github.com/LetA-Tech/mcfo-neonlink
|
|
6
|
+
Project-URL: Documentation, https://github.com/LetA-Tech/mcfo-neonlink/tree/main/py3
|
|
7
|
+
Project-URL: Repository, https://github.com/LetA-Tech/mcfo-neonlink.git
|
|
8
|
+
Project-URL: Changelog, https://github.com/LetA-Tech/mcfo-neonlink/blob/main/py3/CHANGELOG.md
|
|
9
|
+
Author-email: LetA Tech <dev@leta.tech>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: async,grpc,mellions,message-broker,neonlink,redis-streams
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Framework :: AsyncIO
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: grpcio-tools>=1.60.0
|
|
26
|
+
Requires-Dist: grpcio>=1.60.0
|
|
27
|
+
Requires-Dist: neoncontract-gen>=1.3.15
|
|
28
|
+
Requires-Dist: protobuf>=4.25.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: grpcio-testing>=1.60.0; extra == 'dev'
|
|
31
|
+
Requires-Dist: mypy>=1.8.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# NeonLink Python SDK
|
|
39
|
+
|
|
40
|
+
Official Python client library for NeonLink message broker. Full feature parity with the Go SDK.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install neonlink-client
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Or install from source:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cd py3
|
|
52
|
+
pip install -e .
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
For development:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install -e ".[dev]"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Requirements
|
|
62
|
+
|
|
63
|
+
- Python >= 3.10
|
|
64
|
+
- gRPC runtime (`grpcio`)
|
|
65
|
+
- Protocol Buffers (`protobuf`)
|
|
66
|
+
|
|
67
|
+
## Quick Start
|
|
68
|
+
|
|
69
|
+
### Publishing Messages
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import asyncio
|
|
73
|
+
from neonlink import NeonLinkClient, ConfigBuilder, MessageBuilder
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
async def main():
|
|
77
|
+
config = (
|
|
78
|
+
ConfigBuilder()
|
|
79
|
+
.with_service_name("my-service")
|
|
80
|
+
.with_address("neonlink:9090")
|
|
81
|
+
.build()
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
async with NeonLinkClient(config) as client:
|
|
85
|
+
request = (
|
|
86
|
+
MessageBuilder()
|
|
87
|
+
.with_stream("my-stream")
|
|
88
|
+
.with_message_type("MyMessage")
|
|
89
|
+
.with_json_payload({"key": "value"})
|
|
90
|
+
.with_idempotency_fields("user-123", "action-456")
|
|
91
|
+
.build()
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
response = await client.publish(request)
|
|
95
|
+
print(f"Published: {response.message_id}")
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
asyncio.run(main())
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Subscribing to Streams
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
import asyncio
|
|
105
|
+
from neonlink import NeonLinkClient, ConfigBuilder
|
|
106
|
+
from neoncontract.messaging.v1 import messaging_pb2
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
async def main():
|
|
110
|
+
config = (
|
|
111
|
+
ConfigBuilder()
|
|
112
|
+
.with_service_name("my-worker")
|
|
113
|
+
.with_address("neonlink:9090")
|
|
114
|
+
.build()
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
async with NeonLinkClient(config) as client:
|
|
118
|
+
client.enable_auto_reconnect()
|
|
119
|
+
|
|
120
|
+
request = messaging_pb2.SubscribeRequest(
|
|
121
|
+
stream="my-stream",
|
|
122
|
+
consumer_group="my-workers",
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
async for message in client.subscribe(request):
|
|
126
|
+
print(f"Received: {message.message_id}")
|
|
127
|
+
|
|
128
|
+
# Process message...
|
|
129
|
+
|
|
130
|
+
await client.ack(messaging_pb2.AckRequest(
|
|
131
|
+
message_id=message.message_id,
|
|
132
|
+
stream=message.stream,
|
|
133
|
+
))
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
asyncio.run(main())
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Configuration
|
|
140
|
+
|
|
141
|
+
### From Code
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from neonlink import ConfigBuilder
|
|
145
|
+
|
|
146
|
+
config = (
|
|
147
|
+
ConfigBuilder()
|
|
148
|
+
.with_service_name("my-service")
|
|
149
|
+
.with_address("neonlink:9090")
|
|
150
|
+
.with_timeout(30.0)
|
|
151
|
+
.with_retry_policy(max_retries=3, initial_backoff=0.1)
|
|
152
|
+
.with_tls(
|
|
153
|
+
cert_path="/path/to/cert.pem",
|
|
154
|
+
key_path="/path/to/key.pem",
|
|
155
|
+
ca_path="/path/to/ca.pem",
|
|
156
|
+
)
|
|
157
|
+
.build()
|
|
158
|
+
)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### From Environment Variables
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from neonlink import NeonLinkConfig
|
|
165
|
+
|
|
166
|
+
config = NeonLinkConfig.from_env()
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Environment variables:
|
|
170
|
+
- `NEONLINK_SERVICE_NAME` (required)
|
|
171
|
+
- `NEONLINK_ADDRESS` (default: `localhost:9090`)
|
|
172
|
+
- `NEONLINK_TIMEOUT` (default: `30`)
|
|
173
|
+
- `NEONLINK_TLS_CERT`
|
|
174
|
+
- `NEONLINK_TLS_KEY`
|
|
175
|
+
- `NEONLINK_TLS_CA`
|
|
176
|
+
- `NEONLINK_TLS_INSECURE`
|
|
177
|
+
|
|
178
|
+
## Middleware
|
|
179
|
+
|
|
180
|
+
Add middleware for logging, retries, timeouts, and metrics:
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
from neonlink import (
|
|
184
|
+
NeonLinkClient,
|
|
185
|
+
LoggingMiddleware,
|
|
186
|
+
RetryMiddleware,
|
|
187
|
+
TimeoutMiddleware,
|
|
188
|
+
MetricsMiddleware,
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
middlewares = [
|
|
192
|
+
LoggingMiddleware(),
|
|
193
|
+
RetryMiddleware(max_retries=3),
|
|
194
|
+
TimeoutMiddleware(timeout=10.0),
|
|
195
|
+
MetricsMiddleware(my_metrics_collector),
|
|
196
|
+
]
|
|
197
|
+
|
|
198
|
+
client = NeonLinkClient(config, middlewares=middlewares)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Idempotency
|
|
202
|
+
|
|
203
|
+
Use the `MessageBuilder` to ensure idempotent message delivery:
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
from neonlink import MessageBuilder
|
|
207
|
+
|
|
208
|
+
# Option 1: Explicit idempotency key
|
|
209
|
+
request = (
|
|
210
|
+
MessageBuilder()
|
|
211
|
+
.with_stream("my-stream")
|
|
212
|
+
.with_message_type("MyMessage")
|
|
213
|
+
.with_idempotency_key("unique-key-123")
|
|
214
|
+
.build()
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
# Option 2: Generate from fields (recommended)
|
|
218
|
+
request = (
|
|
219
|
+
MessageBuilder()
|
|
220
|
+
.with_stream("my-stream")
|
|
221
|
+
.with_message_type("MyMessage")
|
|
222
|
+
.with_idempotency_fields("user-123", "action-456", "timestamp")
|
|
223
|
+
.build()
|
|
224
|
+
)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Proto Definitions
|
|
228
|
+
|
|
229
|
+
The SDK uses protobuf definitions from the `neoncontract` package, which is automatically
|
|
230
|
+
installed as a dependency. The package provides all message types for the NeonLink gRPC service.
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
# Import protobuf types directly from neoncontract
|
|
234
|
+
from neoncontract.messaging.v1 import messaging_pb2
|
|
235
|
+
|
|
236
|
+
# Available types:
|
|
237
|
+
# - messaging_pb2.PublishRequest
|
|
238
|
+
# - messaging_pb2.PublishResponse
|
|
239
|
+
# - messaging_pb2.SubscribeRequest
|
|
240
|
+
# - messaging_pb2.StreamMessage
|
|
241
|
+
# - messaging_pb2.AckRequest
|
|
242
|
+
# - messaging_pb2.AckResponse
|
|
243
|
+
# - messaging_pb2.NackRequest
|
|
244
|
+
# - messaging_pb2.NackResponse
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Development
|
|
248
|
+
|
|
249
|
+
### Running Tests
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
pytest
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
With coverage:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
pytest --cov=neonlink --cov-report=html
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Type Checking
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
mypy neonlink
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Linting
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
ruff check neonlink
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Examples
|
|
274
|
+
|
|
275
|
+
See the `examples/` directory for complete examples:
|
|
276
|
+
|
|
277
|
+
- `publish.py` - Basic publishing
|
|
278
|
+
- `subscribe.py` - Subscribing and processing
|
|
279
|
+
- `middleware_example.py` - Using middleware
|
|
280
|
+
- `finai_integration.py` - FinAI service integration
|
|
281
|
+
- `retry_example.py` - Retry behavior
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
MIT License - see LICENSE file.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
neonlink_client-1.3.25.dist-info/METADATA,sha256=fcwUCUzf1gEDCfW4AmGlP3OxxOgBw3RddygefUm8Ofg,6561
|
|
2
|
+
neonlink_client-1.3.25.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
3
|
+
neonlink_client-1.3.25.dist-info/licenses/LICENSE,sha256=LrGczAiQ-svrJ-ay3umnLwUD9mh5jwLNLCEOD0PTQsk,1066
|
|
4
|
+
neonlink_client-1.3.25.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 LetA Tech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|