Skip to content

Commit b3b86e3

Browse files
committed
chore: update naming
1 parent 9a018d6 commit b3b86e3

8 files changed

Lines changed: 61 additions & 43 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ client = Replane(
8181
# Default context applied to all get() calls
8282
context={"environment": "production"},
8383

84-
# Fallback values used if server is unavailable during init
85-
fallbacks={
84+
# Default values used if server is unavailable during init
85+
defaults={
8686
"rate-limit": 100,
8787
"feature-enabled": False,
8888
},

docs/source/configuration.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ replane = Replane(
1616

1717
# Optional
1818
context={"environment": "production"},
19-
fallbacks={"rate-limit": 100, "feature-enabled": False},
19+
defaults={"rate-limit": 100, "feature-enabled": False},
2020
required=["rate-limit", "feature-enabled"],
2121
request_timeout_ms=2000,
2222
initialization_timeout_ms=5000,
@@ -29,6 +29,7 @@ replane = Replane(
2929
### Required Options
3030

3131
#### `base_url`
32+
3233
- **Type:** `str`
3334
- **Required:** Yes
3435

@@ -40,6 +41,7 @@ base_url="http://localhost:3000" # Local development
4041
```
4142

4243
#### `sdk_key`
44+
4345
- **Type:** `str`
4446
- **Required:** Yes
4547

@@ -53,6 +55,7 @@ sdk_key="rp_test_xyz789..." # Testing/staging
5355
### Optional Options
5456

5557
#### `context`
58+
5659
- **Type:** `dict[str, str | int | float | bool | None]`
5760
- **Default:** `{}`
5861

@@ -76,28 +79,31 @@ value = replane.get("config-name", context={"user_id": "123"})
7679
# Effective context: {"environment": "production", "region": "us-east", "user_id": "123"}
7780
```
7881

79-
#### `fallbacks`
82+
#### `defaults`
83+
8084
- **Type:** `dict[str, Any]`
8185
- **Default:** `{}`
8286

83-
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.
87+
Default 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.
8488

8589
```python
8690
replane = Replane(
8791
...,
88-
fallbacks={
92+
defaults={
8993
"rate-limit": 100,
9094
"feature-enabled": False,
9195
"max-connections": 10,
9296
},
9397
)
9498
```
9599

96-
Fallbacks are used in two scenarios:
100+
Defaults are used in two scenarios:
101+
97102
1. During initialization if a config isn't returned by the server
98103
2. If `get()` is called before initialization completes
99104

100105
#### `required`
106+
101107
- **Type:** `list[str]`
102108
- **Default:** `[]`
103109

@@ -114,6 +120,7 @@ replane = Replane(
114120
This is useful for catching configuration errors early rather than at runtime.
115121

116122
#### `request_timeout_ms`
123+
117124
- **Type:** `int`
118125
- **Default:** `2000` (2 seconds)
119126

@@ -127,6 +134,7 @@ replane = Replane(
127134
```
128135

129136
#### `initialization_timeout_ms`
137+
130138
- **Type:** `int`
131139
- **Default:** `5000` (5 seconds)
132140

@@ -142,6 +150,7 @@ replane = Replane(
142150
If initialization times out, a `TimeoutError` is raised.
143151

144152
#### `retry_delay_ms`
153+
145154
- **Type:** `int`
146155
- **Default:** `200` (0.2 seconds)
147156

@@ -155,6 +164,7 @@ replane = Replane(
155164
```
156165

157166
#### `inactivity_timeout_ms`
167+
158168
- **Type:** `int`
159169
- **Default:** `30000` (30 seconds)
160170

@@ -168,6 +178,7 @@ replane = Replane(
168178
```
169179

170180
#### `debug`
181+
171182
- **Type:** `bool`
172183
- **Default:** `False`
173184

@@ -181,6 +192,7 @@ replane = Replane(
181192
```
182193

183194
When enabled, you'll see logs for:
195+
184196
- Client initialization parameters
185197
- SSE connection attempts and status
186198
- Each config loaded from the server
@@ -190,6 +202,7 @@ When enabled, you'll see logs for:
190202
- Client close operations
191203

192204
Example output:
205+
193206
```
194207
2024-01-15 10:30:00 [DEBUG] replane: Initializing Replane: base_url=https://replane.example.com, ...
195208
2024-01-15 10:30:00 [DEBUG] replane: connect() called, wait=True

docs/source/errors.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ ReplaneError (base class)
1919

2020
Each `ReplaneError` has a `code` attribute from the `ErrorCode` enum:
2121

22-
| Code | Description |
23-
|------|-------------|
24-
| `not_found` | Config doesn't exist |
25-
| `timeout` | Operation timed out |
26-
| `network_error` | Network request failed |
27-
| `auth_error` | Authentication failed (invalid SDK key) |
28-
| `forbidden` | Access denied |
29-
| `server_error` | Server returned 5xx error |
30-
| `client_error` | Client error (4xx) |
31-
| `closed` | Client has been closed |
32-
| `not_initialized` | Client not yet initialized |
33-
| `missing_dependency` | Required dependency not installed |
34-
| `unknown` | Unknown error |
22+
| Code | Description |
23+
| -------------------- | --------------------------------------- |
24+
| `not_found` | Config doesn't exist |
25+
| `timeout` | Operation timed out |
26+
| `network_error` | Network request failed |
27+
| `auth_error` | Authentication failed (invalid SDK key) |
28+
| `forbidden` | Access denied |
29+
| `server_error` | Server returned 5xx error |
30+
| `client_error` | Client error (4xx) |
31+
| `closed` | Client has been closed |
32+
| `not_initialized` | Client not yet initialized |
33+
| `missing_dependency` | Required dependency not installed |
34+
| `unknown` | Unknown error |
3535

3636
## Handling Errors
3737

@@ -103,18 +103,19 @@ except ConfigNotFoundError as e:
103103
```
104104

105105
**Attributes:**
106+
106107
- `config_name: str` - Name of the missing config
107108

108-
**Prevention:** Use `default` parameter or `fallbacks` option:
109+
**Prevention:** Use `default` parameter or `defaults` option:
109110

110111
```python
111112
# With default
112113
value = replane.get("config", default="fallback")
113114

114-
# With fallbacks during init
115+
# With defaults during init
115116
replane = Replane(
116117
...,
117-
fallbacks={"config": "fallback"},
118+
defaults={"config": "fallback"},
118119
)
119120
```
120121

@@ -132,6 +133,7 @@ except TimeoutError as e:
132133
```
133134

134135
**Attributes:**
136+
135137
- `timeout_ms: int | None` - Timeout value in milliseconds
136138

137139
**Prevention:** Increase timeout values:
@@ -158,6 +160,7 @@ except AuthenticationError:
158160
```
159161

160162
**Common causes:**
163+
161164
- Invalid SDK key
162165
- SDK key for wrong environment
163166
- Revoked SDK key
@@ -178,6 +181,7 @@ except NetworkError as e:
178181
```
179182

180183
**Common causes:**
184+
181185
- Server unreachable
182186
- DNS resolution failed
183187
- Connection refused
@@ -232,6 +236,7 @@ except MissingDependencyError as e:
232236
```
233237

234238
**Attributes:**
239+
235240
- `dependency: str` - Name of the missing package
236241
- `feature: str` - Feature that requires the dependency
237242

@@ -251,7 +256,7 @@ except ReplaneError as e:
251256
## Best Practices
252257

253258
1. **Catch specific exceptions first**, then fall back to `ReplaneError`
254-
2. **Use fallbacks** for resilience against missing configs
259+
2. **Use defaults** for resilience against missing configs
255260
3. **Log errors** with their codes for debugging
256261
4. **Don't catch and ignore** - at minimum, log the error
257262
5. **Use `default` parameter** instead of catching `ConfigNotFoundError` when appropriate

docs/source/frameworks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,4 +366,4 @@ if __name__ == "__main__":
366366
2. **Close on shutdown** - Always close the client when your application shuts down
367367
3. **Use context managers** - When possible, use `with`/`async with` for automatic cleanup
368368
4. **Handle errors** - Wrap initialization in try/except for graceful degradation
369-
5. **Use fallbacks** - Configure fallback values for resilience
369+
5. **Use defaults** - Configure default values for resilience

replane/_async.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(
8484
sdk_key: str,
8585
*,
8686
context: dict[str, ContextValue] | None = None,
87-
fallbacks: dict[str, Any] | None = None,
87+
defaults: dict[str, Any] | None = None,
8888
required: list[str] | None = None,
8989
request_timeout_ms: int = 2000,
9090
initialization_timeout_ms: int = 5000,
@@ -99,7 +99,7 @@ def __init__(
9999
base_url: Base URL of the Replane server.
100100
sdk_key: SDK key for authentication.
101101
context: Default context for override evaluation.
102-
fallbacks: Fallback values for configs if not loaded from server.
102+
defaults: Default values for configs if not loaded or abs from server.
103103
required: List of config names that must be present on init.
104104
request_timeout_ms: Timeout for HTTP requests in milliseconds.
105105
initialization_timeout_ms: Timeout for initial connection.
@@ -130,15 +130,15 @@ def __init__(
130130
)
131131
if context:
132132
logger.debug("Default context: %s", context)
133-
if fallbacks:
134-
logger.debug("Fallback configs: %s", list(fallbacks.keys()))
133+
if defaults:
134+
logger.debug("Default configs: %s", list(defaults.keys()))
135135
if required:
136136
logger.debug("Required configs: %s", required)
137137

138138
self._base_url = base_url.rstrip("/")
139139
self._sdk_key = sdk_key
140140
self._context = context or {}
141-
self._fallbacks = fallbacks or {}
141+
self._defaults = defaults or {}
142142
self._required = set(required or [])
143143
self._request_timeout = request_timeout_ms / 1000.0
144144
self._init_timeout = initialization_timeout_ms / 1000.0
@@ -150,8 +150,8 @@ def __init__(
150150
self._configs: dict[str, Config] = {}
151151
self._lock = asyncio.Lock()
152152

153-
# Initialize fallbacks
154-
for name, value in self._fallbacks.items():
153+
# Initialize defaults
154+
for name, value in self._defaults.items():
155155
self._configs[name] = Config(name=name, value=value)
156156

157157
# Subscription callbacks

replane/_sync.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(
8383
sdk_key: str,
8484
*,
8585
context: dict[str, ContextValue] | None = None,
86-
fallbacks: dict[str, Any] | None = None,
86+
defaults: dict[str, Any] | None = None,
8787
required: list[str] | None = None,
8888
request_timeout_ms: int = 2000,
8989
initialization_timeout_ms: int = 5000,
@@ -98,7 +98,7 @@ def __init__(
9898
base_url: Base URL of the Replane server.
9999
sdk_key: SDK key for authentication.
100100
context: Default context for override evaluation.
101-
fallbacks: Fallback values for configs if not loaded from server.
101+
defaults: Default values for configs if not loaded from server.
102102
required: List of config names that must be present on init.
103103
request_timeout_ms: Timeout for HTTP requests in milliseconds.
104104
initialization_timeout_ms: Timeout for initial connection.
@@ -123,14 +123,14 @@ def __init__(
123123
)
124124
if context:
125125
logger.debug("Default context: %s", context)
126-
if fallbacks:
127-
logger.debug("Fallback configs: %s", list(fallbacks.keys()))
126+
if defaults:
127+
logger.debug("Default configs: %s", list(defaults.keys()))
128128
if required:
129129
logger.debug("Required configs: %s", required)
130130
self._base_url = base_url.rstrip("/")
131131
self._sdk_key = sdk_key
132132
self._context = context or {}
133-
self._fallbacks = fallbacks or {}
133+
self._defaults = defaults or {}
134134
self._required = set(required or [])
135135
self._request_timeout = request_timeout_ms / 1000.0
136136
self._init_timeout = initialization_timeout_ms / 1000.0
@@ -142,8 +142,8 @@ def __init__(
142142
self._configs: dict[str, Config] = {}
143143
self._lock = threading.RLock()
144144

145-
# Initialize fallbacks
146-
for name, value in self._fallbacks.items():
145+
# Initialize defaults
146+
for name, value in self._defaults.items():
147147
self._configs[name] = Config(name=name, value=value)
148148

149149
# Subscription callbacks

tests/test_async_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ async def test_fallback_configs(self, mock_server: MockSSEServer):
182182
async with AsyncReplane(
183183
base_url=mock_server.url,
184184
sdk_key="rp_test_key",
185-
fallbacks={"fallback-config": "fallback-value"},
185+
defaults={"fallback-config": "fallback-value"},
186186
) as client:
187187
assert client.get("from-server") == "server"
188188
assert client.get("fallback-config") == "fallback-value"
@@ -194,7 +194,7 @@ async def test_server_overrides_fallback(self, mock_server: MockSSEServer):
194194
async with AsyncReplane(
195195
base_url=mock_server.url,
196196
sdk_key="rp_test_key",
197-
fallbacks={"config": "from-fallback"},
197+
defaults={"config": "from-fallback"},
198198
) as client:
199199
assert client.get("config") == "from-server"
200200

tests/test_sync_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def test_fallback_configs(self, mock_server: MockSSEServer):
182182
with Replane(
183183
base_url=mock_server.url,
184184
sdk_key="rp_test_key",
185-
fallbacks={"fallback-config": "fallback-value"},
185+
defaults={"fallback-config": "fallback-value"},
186186
) as client:
187187
assert client.get("from-server") == "server"
188188
assert client.get("fallback-config") == "fallback-value"
@@ -194,7 +194,7 @@ def test_server_overrides_fallback(self, mock_server: MockSSEServer):
194194
with Replane(
195195
base_url=mock_server.url,
196196
sdk_key="rp_test_key",
197-
fallbacks={"config": "from-fallback"},
197+
defaults={"config": "from-fallback"},
198198
) as client:
199199
assert client.get("config") == "from-server"
200200

0 commit comments

Comments
 (0)