-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimplementing-launchdarkly.mdc
More file actions
79 lines (40 loc) · 2.23 KB
/
Copy pathimplementing-launchdarkly.mdc
File metadata and controls
79 lines (40 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
description:
globs:
alwaysApply: false
---
implementing-launchdarkly.mdc:
Rule 1: Use LaunchDarkly SDK Wrappers and Utility Functions
- All applications must use shared SDK utility libraries or wrappers to standardize implementation.
Wrappers must expose:
- getLDConfig() – returns a pre-configured LDConfig object with environment-specific defaults
- getSDKKey() – securely retrieves the SDK key for the environment
- initializeLaunchDarkly() – performs singleton-safe client initialization with timeout handling
- Wrappers must not fully abstract the core SDK. They should return SDK-native objects to allow flexibility and upgrades.
Rule 2: LaunchDarkly Configuration Must Be Environment-Aware
- SDK configuration wrappers must integrate with existing environment-specific configuration management systems (e.g., environment variables, secrets managers).
If a proxy is required:
- A shared function like defaultLaunchDarklyHTTPConfiguration() must parse and apply proxy settings from environment variables (e.g., http_proxy).
- Configuration wrappers must allow consumers to override defaults without modifying shared code.
Rule 3: LaunchDarkly Client Singleton Initialization Pattern
- SDK must be initialized once, at application startup, using a singleton-safe pattern.
Initialization must include:
- A timeout (recommended: 1–5 seconds)
- Metrics collection for latency/error tracking
- Graceful fallback to default values if initialization fails
- Example: use Promise.race() or equivalent to cap startup latency in async environments.
Rule 4: LaunchDarkly Client Clean Shutdown Required
- All applications must flush and close the SDK on shutdown.
- Use shared setCleanupHandlers() utilities that hook into process signals (SIGINT, SIGTERM, etc.).
Rule 5: LaunchDarkly Optional Enhancements
Implement optional helpers for:
- Bootstrapping flag values at startup
- Subscribing to flag changes
- Exporting metrics for initialization and flag evaluations
Rule 6: LaunchDarkly SDK Config Must Be Lightweight and Reproducible
- Config utilities must be easy to consume and adapt across environments and teams.
The default configuration must support:
- Proxy settings
- Logging
- Event buffer tuning
- Relay proxy or daemon mode