Commit fd53b02
authored
refactor: extract shared BasePartyClient to reduce duplicate gRPC connection code (#400)
* feat(clients): extract shared BasePartyClient to shared/pkg/clients
Introduces BasePartyClient infrastructure to reduce code duplication
between tenant and current-account services when connecting to the
Party service. The shared client handles common gRPC connection setup,
configuration validation, timeout defaults, tracer interceptors, and
context propagation (correlation ID and organization ID).
* refactor(tenant): use shared BasePartyClient for Party service communication
Refactor tenant service's PartyClient to embed shared BasePartyClient,
removing ~75 lines of duplicate connection setup code. The tenant-specific
error handling for RegisterParty (AlreadyExists, InvalidArgument, Unavailable,
DeadlineExceeded) is preserved while common gRPC infrastructure is delegated
to the shared package.
* refactor(current-account): use shared BasePartyClient for party service communication
Refactor current-account service's PartyClient to embed BasePartyClient from
shared/pkg/clients, removing ~70 lines of duplicate connection setup code.
Changes:
- Remove local PartyClientConfig struct (use sharedclients.PartyClientConfig)
- Remove local connection fields and constructor logic (delegate to BasePartyClient)
- Remove local Close() method (inherited from BasePartyClient via embedding)
- Update GetParty to use PrepareContext() for context preparation
- Update tests to use sharedclients.PartyClientConfig and ErrPartyServiceNameRequired
- Update main.go and grpc_service.go to use sharedclients.PartyClientConfig
The service-specific errors (ErrPartyNotFound, ErrPartyNotActive) and business
logic (ValidateParty status check) remain in the current-account package.
Part of tech debt cleanup task 19 - Extract shared PartyClient.
---------
Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>1 parent 034122d commit fd53b02
9 files changed
Lines changed: 504 additions & 204 deletions
File tree
- services
- current-account
- clients
- cmd
- service
- tenant
- clients
- cmd
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | | - | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
18 | | - | |
| 15 | + | |
19 | 16 | | |
20 | | - | |
| 17 | + | |
21 | 18 | | |
22 | | - | |
| 19 | + | |
23 | 20 | | |
24 | | - | |
25 | | - | |
26 | 21 | | |
27 | 22 | | |
28 | | - | |
| 23 | + | |
29 | 24 | | |
30 | 25 | | |
31 | 26 | | |
32 | 27 | | |
33 | 28 | | |
34 | | - | |
| 29 | + | |
35 | 30 | | |
36 | 31 | | |
37 | 32 | | |
38 | 33 | | |
39 | 34 | | |
40 | 35 | | |
41 | | - | |
| 36 | + | |
42 | 37 | | |
43 | 38 | | |
44 | 39 | | |
45 | 40 | | |
46 | | - | |
| 41 | + | |
47 | 42 | | |
48 | 43 | | |
49 | 44 | | |
50 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
51 | 49 | | |
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 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
| 50 | + | |
84 | 51 | | |
85 | 52 | | |
86 | 53 | | |
87 | 54 | | |
88 | 55 | | |
89 | 56 | | |
90 | | - | |
| 57 | + | |
91 | 58 | | |
92 | 59 | | |
93 | 60 | | |
94 | 61 | | |
95 | | - | |
96 | 62 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
121 | 66 | | |
122 | | - | |
| 67 | + | |
123 | 68 | | |
124 | 69 | | |
125 | 70 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 71 | + | |
130 | 72 | | |
131 | 73 | | |
132 | 74 | | |
133 | | - | |
| 75 | + | |
134 | 76 | | |
135 | 77 | | |
136 | 78 | | |
| |||
144 | 86 | | |
145 | 87 | | |
146 | 88 | | |
147 | | - | |
| 89 | + | |
148 | 90 | | |
149 | | - | |
| 91 | + | |
150 | 92 | | |
151 | 93 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 94 | + | |
156 | 95 | | |
157 | 96 | | |
158 | 97 | | |
| |||
165 | 104 | | |
166 | 105 | | |
167 | 106 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | | - | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | | - | |
| 71 | + | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
| |||
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | | - | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
126 | | - | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
144 | | - | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | | - | |
| 165 | + | |
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
| |||
185 | 186 | | |
186 | 187 | | |
187 | 188 | | |
188 | | - | |
| 189 | + | |
189 | 190 | | |
190 | 191 | | |
191 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
| 444 | + | |
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| |||
0 commit comments