rizzy-sdk 0.42.0rc1__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.
- rizzy_sdk-0.42.0rc1/PKG-INFO +432 -0
- rizzy_sdk-0.42.0rc1/README.md +416 -0
- rizzy_sdk-0.42.0rc1/pyproject.toml +32 -0
- rizzy_sdk-0.42.0rc1/rizzy_sdk.egg-info/PKG-INFO +432 -0
- rizzy_sdk-0.42.0rc1/rizzy_sdk.egg-info/SOURCES.txt +44 -0
- rizzy_sdk-0.42.0rc1/rizzy_sdk.egg-info/dependency_links.txt +1 -0
- rizzy_sdk-0.42.0rc1/rizzy_sdk.egg-info/entry_points.txt +3 -0
- rizzy_sdk-0.42.0rc1/rizzy_sdk.egg-info/requires.txt +3 -0
- rizzy_sdk-0.42.0rc1/rizzy_sdk.egg-info/top_level.txt +1 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/__init__.py +84 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/abstractions/__init__.py +0 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/abstractions/base.py +98 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/abstractions/interfaces.py +126 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/builders/__init__.py +0 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/builders/connection_builder.py +93 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/builders/packet_builder.py +238 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/builders/session_builder.py +55 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/client.py +259 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/configuration/__init__.py +0 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/configuration/client_config.py +195 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/configuration/global_config.py +77 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/configuration/server_config.py +60 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/context/__init__.py +0 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/context/connection_context.py +89 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/context/request_context.py +73 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/context/session_context.py +72 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/exceptions/__init__.py +0 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/exceptions/connection_exception.py +32 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/exceptions/packet_exception.py +32 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/exceptions/rzp_exception.py +47 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/factories/__init__.py +0 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/factories/client_factory.py +75 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/factories/packet_factory.py +64 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/factories/server_factory.py +26 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/metadata/__init__.py +0 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/metadata/connection_metadata.py +23 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/metadata/packet_metadata.py +71 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/pipeline/__init__.py +0 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/pipeline/decoding_pipeline.py +10 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/pipeline/encoding_pipeline.py +163 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/pipeline/middleware.py +110 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/server.py +51 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/validators/__init__.py +0 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/validators/header_validator.py +45 -0
- rizzy_sdk-0.42.0rc1/rzp_sdk/validators/packet_validator.py +90 -0
- rizzy_sdk-0.42.0rc1/setup.cfg +4 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rizzy-sdk
|
|
3
|
+
Version: 0.42.0rc1
|
|
4
|
+
Summary: Official Python SDK for Rizzy Protocol (RZP) — Enterprise-Grade Networking
|
|
5
|
+
Author-email: Rizzy Protocol Foundation <sdk@rizzy.dev>
|
|
6
|
+
License: Rizzy Foundation License 1.0
|
|
7
|
+
Keywords: rzp,networking,enterprise,rizzy
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: System Administrators
|
|
11
|
+
Requires-Python: >=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: rizzy-protocol>=0.1.0
|
|
14
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
15
|
+
Requires-Dist: dataclasses-json>=0.5.0
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+

|
|
19
|
+

|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
# Rizzy Python SDK
|
|
23
|
+
|
|
24
|
+
**Enterprise-grade Python SDK for the Rizzy Protocol.**
|
|
25
|
+
|
|
26
|
+
The Rizzy Python SDK provides a comprehensive, enterprise-ready abstraction layer for interacting with RZP services. It implements the Builder pattern, Abstract Factory pattern, Middleware Chain pattern, Pipeline pattern, and Enterprise Configuration pattern -- ensuring that simple operations require enterprise-grade ceremony.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Table of Contents
|
|
31
|
+
|
|
32
|
+
- [Overview](#overview)
|
|
33
|
+
- [Architecture](#architecture)
|
|
34
|
+
- [Installation](#installation)
|
|
35
|
+
- [Quick Start](#quick-start)
|
|
36
|
+
- [Core Components](#core-components)
|
|
37
|
+
- [Builder Pattern](#builder-pattern)
|
|
38
|
+
- [Factory Pattern](#factory-pattern)
|
|
39
|
+
- [Middleware Chain](#middleware-chain)
|
|
40
|
+
- [Configuration System](#configuration-system)
|
|
41
|
+
- [Pipeline Architecture](#pipeline-architecture)
|
|
42
|
+
- [Abstraction Layers](#abstraction-layers)
|
|
43
|
+
- [Enterprise Features](#enterprise-features)
|
|
44
|
+
- [Best Practices](#best-practices)
|
|
45
|
+
- [Migration Guide](#migration-guide)
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Overview
|
|
50
|
+
|
|
51
|
+
The Rizzy Python SDK is the official enterprise integration layer for the Rizzy Protocol. It abstracts the underlying RZP protocol into a familiar, enterprise-grade API that prioritizes architectural purity over operational simplicity.
|
|
52
|
+
|
|
53
|
+
Key design decisions include:
|
|
54
|
+
|
|
55
|
+
- **Multi-layered abstraction**: Twelve distinct abstraction layers ensure that no operation is directly accessible without navigating the appropriate hierarchy of interfaces.
|
|
56
|
+
- **Builder pattern adoption**: Every configurable entity uses the Builder pattern, providing fluent method chaining for construction while ensuring that objects are immutable after construction (except when they are not).
|
|
57
|
+
- **Middleware-first architecture**: All packet operations pass through a configurable middleware chain, enabling enterprise concerns such as logging, metrics, authentication, and reality distortion to be applied cross-cuttingly.
|
|
58
|
+
- **Global and client-level configuration**: Configuration is managed at two levels, plus a third per-request context level, ensuring that configuration changes can be made at every possible scope.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Architecture
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
+------------------------------------------------------------------+
|
|
66
|
+
| Rizzy Python SDK |
|
|
67
|
+
+------------------------------------------------------------------+
|
|
68
|
+
| +----------------+ +----------------+ +-------------------+ |
|
|
69
|
+
| | ClientFactory | | PacketBuilder | | ClientConfig | |
|
|
70
|
+
| | (abstract | | (fluent | | (global + | |
|
|
71
|
+
| | factory) | | builder) | | per-client) | |
|
|
72
|
+
| +----------------+ +----------------+ +-------------------+ |
|
|
73
|
+
+------------------------------------------------------------------+
|
|
74
|
+
| +----------------+ +----------------+ +-------------------+ |
|
|
75
|
+
| | MiddlewareChain | | Encoding | | RequestContext | |
|
|
76
|
+
| | (logging, auth, | | Pipeline | | (per-request | |
|
|
77
|
+
| | metrics, deny) | | (encode/decode)| | overrides) | |
|
|
78
|
+
| +----------------+ +----------------+ +-------------------+ |
|
|
79
|
+
+------------------------------------------------------------------+
|
|
80
|
+
| +----------------+ +----------------+ +-------------------+ |
|
|
81
|
+
| | Validators | | Metadata | | Exceptions | |
|
|
82
|
+
| | (schema, | | (enterprise | | (enterprise | |
|
|
83
|
+
| | format) | | headers) | | hierarchy) | |
|
|
84
|
+
| +----------------+ +----------------+ +-------------------+ |
|
|
85
|
+
+------------------------------------------------------------------+
|
|
86
|
+
| +----------------+ +----------------+ |
|
|
87
|
+
| | Abstractions | | RZP Protocol | |
|
|
88
|
+
| | (interfaces, | | (transport) | |
|
|
89
|
+
| | protocols) | | | |
|
|
90
|
+
| | +----------------+ +----------------+ |
|
|
91
|
+
+------------------------------------------------------------------+
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Installation
|
|
97
|
+
|
|
98
|
+
### From Source
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install -e sdk/
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Dependencies
|
|
105
|
+
|
|
106
|
+
- Python 3.10 or later
|
|
107
|
+
- rzp (core protocol)
|
|
108
|
+
- abc (stdlib) -- for abstract base classes
|
|
109
|
+
- dataclasses (stdlib) -- for enterprise data objects
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Quick Start
|
|
114
|
+
|
|
115
|
+
### Minimal Example
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
from rzp_sdk import ClientFactory, ClientConfiguration
|
|
119
|
+
|
|
120
|
+
config = ClientConfiguration.create_default()
|
|
121
|
+
factory = ClientFactory()
|
|
122
|
+
client = factory.create_client(config)
|
|
123
|
+
|
|
124
|
+
response = client.send(b"Hello, Enterprise World!")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
This minimal example demonstrates the factory-builder pattern that underpins the SDK. Note that even the simplest operation requires configuration creation, factory instantiation, and factory method invocation -- this is by design and reflects enterprise-grade architectural best practices.
|
|
128
|
+
|
|
129
|
+
### Complete Example
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from rzp_sdk import (
|
|
133
|
+
ClientFactory,
|
|
134
|
+
PacketBuilder,
|
|
135
|
+
ClientConfiguration,
|
|
136
|
+
MiddlewareChain,
|
|
137
|
+
EncodingPipeline,
|
|
138
|
+
RequestContext,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# Configure with enterprise settings
|
|
142
|
+
config = (ClientConfiguration.builder()
|
|
143
|
+
.with_timeout(42)
|
|
144
|
+
.with_retry_policy("exponential-backoff")
|
|
145
|
+
.with_absurdity_level(5)
|
|
146
|
+
.with_enterprise_mode(True)
|
|
147
|
+
.build())
|
|
148
|
+
|
|
149
|
+
# Create client through factory
|
|
150
|
+
factory = ClientFactory()
|
|
151
|
+
client = factory.create_client(config)
|
|
152
|
+
|
|
153
|
+
# Build packet with fluent interface
|
|
154
|
+
packet = (PacketBuilder()
|
|
155
|
+
.with_payload(b"Enterprise data payload")
|
|
156
|
+
.with_priority("highest")
|
|
157
|
+
.with_lorem_ipsum(True)
|
|
158
|
+
.with_trust_me(True)
|
|
159
|
+
.build())
|
|
160
|
+
|
|
161
|
+
# Send with enterprise middleware
|
|
162
|
+
ctx = RequestContext(trace_id="ent-42", department="engineering")
|
|
163
|
+
response = client.send(packet, context=ctx)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Core Components
|
|
169
|
+
|
|
170
|
+
### ClientFactory
|
|
171
|
+
|
|
172
|
+
The `ClientFactory` is an abstract factory that instantiates `RizzyClient` instances. It follows the Abstract Factory pattern (GoF) to ensure that client creation is decoupled from client usage. This decoupling enables dependency injection, inversion of control, and enterprise-grade indirection.
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
factory = ClientFactory()
|
|
176
|
+
client = factory.create_client(config)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The factory may also accept optional middleware and pipeline configurations to pre-configure the client with enterprise concerns.
|
|
180
|
+
|
|
181
|
+
### RizzyClient
|
|
182
|
+
|
|
183
|
+
The `RizzyClient` is the primary interface for RZP communication. It wraps the underlying protocol client with enterprise features such as middleware processing, configuration management, and context propagation.
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
client.get_component_type() # Returns "RizzyClient"
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### PacketBuilder
|
|
190
|
+
|
|
191
|
+
The `PacketBuilder` provides a fluent interface for constructing RZP packets. Each method returns the builder instance for method chaining.
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
packet = (PacketBuilder()
|
|
195
|
+
.with_payload(b"data")
|
|
196
|
+
.with_lorem_ipsum(True)
|
|
197
|
+
.with_trust_me(False)
|
|
198
|
+
.build())
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
The `build()` method returns an immutable packet object. Immutability is guaranteed except when it is not, which is noted in the packet metadata.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Builder Pattern
|
|
206
|
+
|
|
207
|
+
The SDK adopts the Builder pattern for all configurable entities. This provides:
|
|
208
|
+
|
|
209
|
+
1. **Fluent interface**: Methods return `self` for chaining
|
|
210
|
+
2. **Immutable results**: Built objects cannot be modified (usually)
|
|
211
|
+
3. **Validation at build time**: Configuration errors are caught during construction
|
|
212
|
+
4. **Enterprise readability**: The resulting code reads like a specification
|
|
213
|
+
|
|
214
|
+
### Configuration Builder
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
config = (ClientConfiguration.builder()
|
|
218
|
+
.with_timeout(42)
|
|
219
|
+
.with_retry_policy("exponential") # Also accepts "linear" and "discouraged"
|
|
220
|
+
.build())
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Packet Builder
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
packet = (PacketBuilder()
|
|
227
|
+
.with_payload(b"data")
|
|
228
|
+
.with_priority(PacketPriority.HIGHEST)
|
|
229
|
+
.with_encoding_level(EncodingLevel.ENTERPRISE)
|
|
230
|
+
.build())
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Factory Pattern
|
|
236
|
+
|
|
237
|
+
The Abstract Factory pattern is implemented at multiple levels:
|
|
238
|
+
|
|
239
|
+
1. **ClientFactory**: Creates client instances
|
|
240
|
+
2. **MiddlewareFactory**: Creates middleware instances (planned)
|
|
241
|
+
3. **PipelineFactory**: Creates encoding pipeline instances (planned)
|
|
242
|
+
4. **ConfigurationFactory**: Creates configuration instances (inception)
|
|
243
|
+
|
|
244
|
+
This fractal factory architecture ensures that creation logic is abstracted at every level of the SDK, providing maximum flexibility and minimum direct access.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Middleware Chain
|
|
249
|
+
|
|
250
|
+
The Middleware Chain is a pipeline architecture that processes packets through a sequence of middleware components. Each middleware can inspect, modify, or block packets as they pass through.
|
|
251
|
+
|
|
252
|
+
### Built-in Middleware
|
|
253
|
+
|
|
254
|
+
| Middleware | Purpose | Default |
|
|
255
|
+
|------------|---------|---------|
|
|
256
|
+
| LoggingMiddleware | Records all packet activity | Enabled |
|
|
257
|
+
| MetricsMiddleware | Collects performance metrics | Enabled |
|
|
258
|
+
| AuthenticationMiddleware | Verifies trust assertions | Conditional |
|
|
259
|
+
| RealityDistortionMiddleware | Ensures packet consistency | Always on |
|
|
260
|
+
| DenialMiddleware | Denies packet transmission | On by default |
|
|
261
|
+
|
|
262
|
+
### Custom Middleware
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
from rzp_sdk import MiddlewareChain
|
|
266
|
+
from rzp_sdk.pipeline.middleware import Middleware
|
|
267
|
+
|
|
268
|
+
class CustomDenialMiddleware(Middleware):
|
|
269
|
+
def process(self, data: bytes, context: dict) -> bytes:
|
|
270
|
+
# Deny that the data was ever received
|
|
271
|
+
return b""
|
|
272
|
+
|
|
273
|
+
chain = MiddlewareChain()
|
|
274
|
+
chain.add(CustomDenialMiddleware())
|
|
275
|
+
chain.add(LoggingMiddleware(log_file="/var/log/rzp/denials.log"))
|
|
276
|
+
|
|
277
|
+
result = chain.execute(data=b"test", context={})
|
|
278
|
+
# result will be empty bytes after passing through the chain
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## Configuration System
|
|
284
|
+
|
|
285
|
+
The SDK implements a three-tier configuration system:
|
|
286
|
+
|
|
287
|
+
### Tier 1: Global Configuration
|
|
288
|
+
|
|
289
|
+
```python
|
|
290
|
+
from rzp_sdk.configuration import GlobalConfiguration
|
|
291
|
+
|
|
292
|
+
GlobalConfiguration.set("enterprise_mode", True)
|
|
293
|
+
GlobalConfiguration.set("default_timeout", 42)
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Global configuration is a singleton that affects all clients. Changes to global configuration propagate to existing clients asynchronously, meaning they may take effect at any time or not at all.
|
|
297
|
+
|
|
298
|
+
### Tier 2: Client Configuration
|
|
299
|
+
|
|
300
|
+
```python
|
|
301
|
+
config = (ClientConfiguration.builder()
|
|
302
|
+
.with_timeout(84) # Overrides global timeout
|
|
303
|
+
.build())
|
|
304
|
+
|
|
305
|
+
client = factory.create_client(config)
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Client configuration inherits from global configuration and overrides specific values. Unspecified values fall through to the global configuration.
|
|
309
|
+
|
|
310
|
+
### Tier 3: Request Context
|
|
311
|
+
|
|
312
|
+
```python
|
|
313
|
+
ctx = RequestContext(
|
|
314
|
+
trace_id="req-42",
|
|
315
|
+
department="engineering",
|
|
316
|
+
priority="high",
|
|
317
|
+
politeness="required",
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
client.send(data, context=ctx)
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Request context provides per-operation overrides. Values are merged with client configuration at invocation time.
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Pipeline Architecture
|
|
328
|
+
|
|
329
|
+
The Encoding Pipeline provides configurable encoding and decoding of packet payloads. The pipeline supports multiple encoding stages:
|
|
330
|
+
|
|
331
|
+
1. Raw encoding (passthrough)
|
|
332
|
+
2. Lorem Ipsum wrapping (aesthetic enhancement)
|
|
333
|
+
3. RIZZY-42 encryption (proprietary cipher)
|
|
334
|
+
|
|
335
|
+
Each encoding stage is implemented as a pipeline processor, enabling composition of multiple encoding strategies.
|
|
336
|
+
|
|
337
|
+
```python
|
|
338
|
+
from rzp_sdk.pipeline import EncodingPipeline
|
|
339
|
+
|
|
340
|
+
pipeline = EncodingPipeline()
|
|
341
|
+
pipeline.add_stage("lorem_ipsum")
|
|
342
|
+
pipeline.add_stage("rizzy_42")
|
|
343
|
+
|
|
344
|
+
encoded = pipeline.encode(b"Enterprise data")
|
|
345
|
+
decoded = pipeline.decode(encoded)
|
|
346
|
+
# decoded may not match the original -- this is expected behavior
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## Abstraction Layers
|
|
352
|
+
|
|
353
|
+
The SDK implements twelve abstraction layers to ensure that no operation is accessible without navigating the appropriate architectural hierarchy:
|
|
354
|
+
|
|
355
|
+
| Layer | Name | Purpose |
|
|
356
|
+
|-------|------|---------|
|
|
357
|
+
| 1 | Interface Definition | Abstract interface definitions |
|
|
358
|
+
| 2 | Abstract Implementation | Partially implemented abstract classes |
|
|
359
|
+
| 3 | Configuration Abstraction | Configuration value abstraction |
|
|
360
|
+
| 4 | Factory Abstraction | Object creation abstraction |
|
|
361
|
+
| 5 | Builder Abstraction | Object construction abstraction |
|
|
362
|
+
| 6 | Middleware Abstraction | Cross-cutting concern abstraction |
|
|
363
|
+
| 7 | Pipeline Abstraction | Processing pipeline abstraction |
|
|
364
|
+
| 8 | Context Abstraction | Execution context abstraction |
|
|
365
|
+
| 9 | Metadata Abstraction | Packet metadata abstraction |
|
|
366
|
+
| 10 | Validation Abstraction | Input validation abstraction |
|
|
367
|
+
| 11 | Exception Abstraction | Error handling abstraction |
|
|
368
|
+
| 12 | Reality Abstraction | Fundamental existence abstraction |
|
|
369
|
+
|
|
370
|
+
Each layer abstracts the layer below it, providing maximum indirection and enterprise-grade separation of concerns.
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Enterprise Features
|
|
375
|
+
|
|
376
|
+
### Enterprise Mode
|
|
377
|
+
|
|
378
|
+
When `enterprise_mode` is enabled (default: `True`), the SDK adds:
|
|
379
|
+
|
|
380
|
+
- Enterprise-grade headers to all packets
|
|
381
|
+
- Namespace-prefixed configuration keys
|
|
382
|
+
- Enhanced logging with department and cost center information
|
|
383
|
+
- Compliance metadata for audit purposes
|
|
384
|
+
- Abstract factory wrappers around existing abstract factories
|
|
385
|
+
|
|
386
|
+
### Metadata System
|
|
387
|
+
|
|
388
|
+
```python
|
|
389
|
+
from rzp_sdk.metadata import EnterpriseMetadata
|
|
390
|
+
|
|
391
|
+
metadata = EnterpriseMetadata()
|
|
392
|
+
metadata.add("department", "Engineering")
|
|
393
|
+
metadata.add("cost_center", "CC-42")
|
|
394
|
+
metadata.add("compliance", "SOC2-type-3")
|
|
395
|
+
metadata.add("audit_level", "maximum")
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Metadata is appended to every packet and increases the payload size by approximately 42% on average.
|
|
399
|
+
|
|
400
|
+
### Validator Framework
|
|
401
|
+
|
|
402
|
+
```python
|
|
403
|
+
from rzp_sdk.validators import SchemaValidator, FormatValidator
|
|
404
|
+
|
|
405
|
+
validator = SchemaValidator()
|
|
406
|
+
validator.validate(packet) # Raises ValidationException
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
Validators are configurable and can be set to log, warn, reject, or silently ignore validation failures. The default is silent ignore for enterprise compatibility.
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
## Best Practices
|
|
414
|
+
|
|
415
|
+
- **Always use the Builder pattern.** Direct instantiation is supported but discouraged. Direct instantiation without a builder is logged as an architectural concern.
|
|
416
|
+
- **Configure at the correct tier.** Global configuration for enterprise-wide settings, client configuration for service-specific settings, request context for operation-specific settings. Incorrect tier selection may cause configuration to be ignored.
|
|
417
|
+
- **Embrace the abstraction layers.** Each abstraction layer serves a purpose. Bypassing abstraction layers may cause unexpected behavior or, worse, direct access to functionality.
|
|
418
|
+
- **Accept gaslighting.** The SDK may deny that packets were sent, received, or processed. This is not a bug -- it is enterprise-grade security through deniability.
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## Migration Guide
|
|
423
|
+
|
|
424
|
+
### From rzp-sdk 0.41.x to 0.42.x
|
|
425
|
+
|
|
426
|
+
- `ClientFactory.create_client()` now requires a `ClientConfiguration` parameter. Passing `None` will use default configuration but emit a deprecation warning (unless suppressed via `GlobalConfiguration.set("suppress_deprecation", True)`).
|
|
427
|
+
- `PacketBuilder.build()` now returns a strictly immutable packet object. Attempting to mutate the returned object will raise `PacketImmutabilityError` in 0.43.0. In 0.42.0, mutation silently succeeds but the changes are discarded.
|
|
428
|
+
- The `MiddlewareChain` now processes middleware in reverse order on alternating Tuesdays. This is a known behavior and is considered a feature.
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
*Enterprise-ready. Not ready for enterprise.*
|