Skip to content

Commit 57c66db

Browse files
committed
feat: update docs
1 parent 36ee28d commit 57c66db

7 files changed

Lines changed: 185 additions & 185 deletions

File tree

docs/source/configuration.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Both `SyncReplaneClient` and `AsyncReplaneClient` accept the same configuration
99
```python
1010
from replane import SyncReplaneClient
1111

12-
client = SyncReplaneClient(
12+
replane = SyncReplaneClient(
1313
# Required
1414
base_url="https://replane.example.com",
1515
sdk_key="sk_live_...",
@@ -60,7 +60,7 @@ Default context applied to all `get()` calls. This is merged with any context pa
6060

6161
```python
6262
# Set default context
63-
client = SyncReplaneClient(
63+
replane = SyncReplaneClient(
6464
...,
6565
context={
6666
"environment": "production",
@@ -69,10 +69,10 @@ client = SyncReplaneClient(
6969
)
7070

7171
# This call uses the default context
72-
value = client.get("config-name")
72+
value = replane.get("config-name")
7373

7474
# This merges with default context
75-
value = client.get("config-name", context={"user_id": "123"})
75+
value = replane.get("config-name", context={"user_id": "123"})
7676
# Effective context: {"environment": "production", "region": "us-east", "user_id": "123"}
7777
```
7878

@@ -83,7 +83,7 @@ value = client.get("config-name", context={"user_id": "123"})
8383
Fallback values used when configs can't be loaded from the server. This is useful for resilience - your application can still function with sensible defaults if the Replane server is unavailable.
8484

8585
```python
86-
client = SyncReplaneClient(
86+
replane = SyncReplaneClient(
8787
...,
8888
fallbacks={
8989
"rate-limit": 100,
@@ -104,7 +104,7 @@ Fallbacks are used in two scenarios:
104104
List of config names that must be present after initialization. If any required config is missing, initialization will fail with a `ConfigNotFoundError`.
105105

106106
```python
107-
client = SyncReplaneClient(
107+
replane = SyncReplaneClient(
108108
...,
109109
required=["rate-limit", "feature-enabled"],
110110
)
@@ -120,7 +120,7 @@ This is useful for catching configuration errors early rather than at runtime.
120120
Timeout for individual HTTP requests to the Replane server.
121121

122122
```python
123-
client = SyncReplaneClient(
123+
replane = SyncReplaneClient(
124124
...,
125125
request_timeout_ms=5000, # 5 seconds
126126
)
@@ -133,7 +133,7 @@ client = SyncReplaneClient(
133133
Maximum time to wait for the client to initialize and receive configs from the server.
134134

135135
```python
136-
client = SyncReplaneClient(
136+
replane = SyncReplaneClient(
137137
...,
138138
initialization_timeout_ms=10000, # 10 seconds
139139
)
@@ -148,7 +148,7 @@ If initialization times out, a `TimeoutError` is raised.
148148
Initial delay between retry attempts when the connection fails. The delay increases exponentially with each retry (up to 30 seconds max).
149149

150150
```python
151-
client = SyncReplaneClient(
151+
replane = SyncReplaneClient(
152152
...,
153153
retry_delay_ms=500, # Start with 0.5 seconds
154154
)
@@ -161,7 +161,7 @@ client = SyncReplaneClient(
161161
Maximum time without receiving any SSE events before the connection is considered stale and reconnected. The server sends periodic keepalive pings, so this timeout should be longer than the server's ping interval.
162162

163163
```python
164-
client = SyncReplaneClient(
164+
replane = SyncReplaneClient(
165165
...,
166166
inactivity_timeout_ms=60000, # 60 seconds
167167
)
@@ -174,7 +174,7 @@ client = SyncReplaneClient(
174174
Enable debug logging to see detailed information about all client activity. This is useful for troubleshooting connection issues, understanding when configs are loaded, and diagnosing override evaluation.
175175

176176
```python
177-
client = SyncReplaneClient(
177+
replane = SyncReplaneClient(
178178
...,
179179
debug=True, # Enable debug logging
180180
)
@@ -207,39 +207,39 @@ If you prefer not to use context managers, you can manage the client lifecycle m
207207
### Sync Client
208208

209209
```python
210-
client = SyncReplaneClient(base_url="...", sdk_key="...")
210+
replane = SyncReplaneClient(base_url="...", sdk_key="...")
211211

212212
# Connect and wait for initialization
213-
client.connect() # Blocks until ready
213+
replane.connect() # Blocks until ready
214214

215215
try:
216-
value = client.get("config")
216+
value = replane.get("config")
217217
finally:
218-
client.close()
218+
replane.close()
219219
```
220220

221221
You can also connect without waiting:
222222

223223
```python
224-
client.connect(wait=False) # Returns immediately
224+
replane.connect(wait=False) # Returns immediately
225225

226226
# Do other initialization...
227227

228228
# Wait for configs when needed
229-
client.wait_for_init()
229+
replane.wait_for_init()
230230
```
231231

232232
### Async Client
233233

234234
```python
235-
client = AsyncReplaneClient(base_url="...", sdk_key="...")
235+
replane = AsyncReplaneClient(base_url="...", sdk_key="...")
236236

237-
await client.connect()
237+
await replane.connect()
238238

239239
try:
240-
value = client.get("config")
240+
value = replane.get("config")
241241
finally:
242-
await client.close()
242+
await replane.close()
243243
```
244244

245245
## Environment Variables
@@ -249,7 +249,7 @@ While the SDK doesn't read environment variables directly, a common pattern is:
249249
```python
250250
import os
251251

252-
client = SyncReplaneClient(
252+
replane = SyncReplaneClient(
253253
base_url=os.environ["REPLANE_URL"],
254254
sdk_key=os.environ["REPLANE_SDK_KEY"],
255255
)

docs/source/errors.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ try:
5050
with SyncReplaneClient(
5151
base_url="https://replane.example.com",
5252
sdk_key="sk_live_...",
53-
) as client:
54-
value = client.get("my-config")
53+
) as replane:
54+
value = replane.get("my-config")
5555
except ConfigNotFoundError as e:
5656
print(f"Config '{e.config_name}' not found")
5757
except TimeoutError as e:
@@ -68,7 +68,7 @@ except ReplaneError as e:
6868
from replane import ReplaneError, ErrorCode
6969

7070
try:
71-
value = client.get("config")
71+
value = replane.get("config")
7272
except ReplaneError as e:
7373
match e.code:
7474
case ErrorCode.NOT_FOUND:
@@ -95,7 +95,7 @@ Raised when requesting a config that doesn't exist.
9595
from replane import ConfigNotFoundError
9696

9797
try:
98-
value = client.get("nonexistent-config")
98+
value = replane.get("nonexistent-config")
9999
except ConfigNotFoundError as e:
100100
print(f"Config not found: {e.config_name}")
101101
# Use a default value instead
@@ -109,10 +109,10 @@ except ConfigNotFoundError as e:
109109

110110
```python
111111
# With default
112-
value = client.get("config", default="fallback")
112+
value = replane.get("config", default="fallback")
113113

114114
# With fallbacks during init
115-
client = SyncReplaneClient(
115+
replane = SyncReplaneClient(
116116
...,
117117
fallbacks={"config": "fallback"},
118118
)
@@ -126,7 +126,7 @@ Raised when an operation exceeds its timeout.
126126
from replane import TimeoutError
127127

128128
try:
129-
client.connect()
129+
replane.connect()
130130
except TimeoutError as e:
131131
print(f"Connection timed out after {e.timeout_ms}ms")
132132
```
@@ -137,7 +137,7 @@ except TimeoutError as e:
137137
**Prevention:** Increase timeout values:
138138

139139
```python
140-
client = SyncReplaneClient(
140+
replane = SyncReplaneClient(
141141
...,
142142
initialization_timeout_ms=10000, # 10 seconds
143143
request_timeout_ms=5000, # 5 seconds
@@ -152,7 +152,7 @@ Raised when the SDK key is invalid or missing.
152152
from replane import AuthenticationError
153153

154154
try:
155-
client.connect()
155+
replane.connect()
156156
except AuthenticationError:
157157
print("Check your SDK key!")
158158
```
@@ -170,7 +170,7 @@ Raised when a network request fails.
170170
from replane import NetworkError
171171

172172
try:
173-
client.connect()
173+
replane.connect()
174174
except NetworkError as e:
175175
print(f"Network error: {e.message}")
176176
if e.__cause__:
@@ -190,12 +190,12 @@ Raised when attempting operations on a closed client.
190190
```python
191191
from replane import ClientClosedError
192192

193-
client = SyncReplaneClient(...)
194-
client.connect()
195-
client.close()
193+
replane = SyncReplaneClient(...)
194+
replane.connect()
195+
replane.close()
196196

197197
try:
198-
client.get("config") # Raises ClientClosedError
198+
replane.get("config") # Raises ClientClosedError
199199
except ClientClosedError:
200200
print("Client was already closed")
201201
```
@@ -207,14 +207,14 @@ Raised when the client hasn't finished initializing.
207207
```python
208208
from replane import NotInitializedError
209209

210-
client = SyncReplaneClient(...)
211-
client.connect(wait=False) # Don't wait
210+
replane = SyncReplaneClient(...)
211+
replane.connect(wait=False) # Don't wait
212212

213213
try:
214-
client.get("config") # May raise if not ready
214+
replane.get("config") # May raise if not ready
215215
except NotInitializedError:
216-
client.wait_for_init() # Wait then retry
217-
value = client.get("config")
216+
replane.wait_for_init() # Wait then retry
217+
value = replane.get("config")
218218
```
219219

220220
### MissingDependencyError
@@ -225,7 +225,7 @@ Raised when using features that require optional dependencies.
225225
from replane import AsyncReplaneClient, MissingDependencyError
226226

227227
try:
228-
client = AsyncReplaneClient(...)
228+
replane = AsyncReplaneClient(...)
229229
except MissingDependencyError as e:
230230
print(f"Missing: {e.dependency}")
231231
print(f"Install with: pip install replane[async]")
@@ -241,7 +241,7 @@ Errors preserve the original cause for debugging:
241241

242242
```python
243243
try:
244-
client.connect()
244+
replane.connect()
245245
except ReplaneError as e:
246246
print(f"Error: {e.message}")
247247
if e.__cause__:
@@ -259,17 +259,17 @@ except ReplaneError as e:
259259
```python
260260
# Good: specific handling
261261
try:
262-
value = client.get("critical-config")
262+
value = replane.get("critical-config")
263263
except ConfigNotFoundError:
264264
logger.error("Critical config missing!")
265265
raise # Re-raise for critical configs
266266

267267
# Good: graceful fallback
268-
value = client.get("optional-config", default="safe-default")
268+
value = replane.get("optional-config", default="safe-default")
269269

270270
# Bad: silently ignoring
271271
try:
272-
value = client.get("config")
272+
value = replane.get("config")
273273
except ReplaneError:
274274
pass # Don't do this!
275275
```

0 commit comments

Comments
 (0)