Commit 690bb43
committed
refactor: consolidate HTTP client creation with factory pattern
This commit introduces HttpClientFactory to centralize HTTP client creation,
eliminating code duplication and ensuring consistent configuration.
New Module: http_client.rs
- HttpClientFactory with three client types:
- https_client(): Cached HTTPS client for external APIs
- unix_socket_client(): For local Unix socket communication
- workload_client(): For IoT Edge workload API
Benefits:
- Eliminates 3 separate OnceLock instances across modules
- Single source of truth for HTTP client configuration
- Shared connection pools improve performance
- Easier to add timeout/retry configuration in future
- Better testability with centralized mocking point
Changes by Module:
- keycloak_client.rs: Use HttpClientFactory::https_client()
- Removed local OnceLock<Client>
- 4 lines removed, cleaner code
- omnect_device_service_client.rs: Use HttpClientFactory::unix_socket_client()
- Simplified client creation
- 3 lines removed
- certificate.rs: Use HttpClientFactory::workload_client()
- Removed manual URI parsing
- 8 lines removed, moved to factory
Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>1 parent b461c46 commit 690bb43
File tree
8 files changed
+105
-393
lines changed- src
8 files changed
+105
-393
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | | - | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | 68 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 69 | + | |
79 | 70 | | |
80 | 71 | | |
81 | 72 | | |
| |||
This file was deleted.
This file was deleted.
0 commit comments