wy471x opened a new pull request, #7487:
URL: https://github.com/apache/shenyu/pull/7487

   ## What
   
   Closes #6605.
   
   The divide, websocket and grpc discovery upstream handlers each carried 
their own copy of the same null-check -> convert -> gray-split -> submit flow, 
plus inline `"warmup"/"10"/"gray"/"false"/"healthCheckEnabled"/"true"` literals 
in the conversion body. This PR lifts the shared parts into 
`shenyu-plugin-base`, mirroring the proven `AbstractDubboPluginDataHandler` 
pattern:
   
   - **`AbstractDiscoveryUpstreamDataHandler<T>`** implements 
`DiscoveryUpstreamDataHandler` once: discovery data null check, upstream 
conversion, gray split, submit, post-submit hook, and the remove path. 
Subclasses only provide their upstream conversion, gray predicate, cache access 
and plugin name.
   - **`UpstreamProps`** is a typed deserializer over the raw discovery `props` 
payload with the property names and defaults in one place, so a typo can no 
longer break warmup/gray/health check parsing for a single plugin.
   
   ## Behavior
   
   Refactor only, conversion semantics per plugin are preserved:
   
   - divide keeps reading warmup/gray/healthCheckEnabled and copying the full 
props map into `Upstream#metadata`;
   - websocket keeps reading warmup/healthCheckEnabled (it does not consume 
gray/metadata today, unchanged);
   - grpc keeps reading healthCheckEnabled, submitting to 
`ApplicationConfigCache` and initializing the client afterwards.
   
   Props parsing for websocket/grpc now goes through the same `Map<String, 
String>` deserializer as divide, which also avoids the `Properties#getProperty` 
cast issue for non-string JSON scalar values.
   
   The DubboUpstream -> Upstream conversions mentioned in the issue 
(`AbstractDubboPluginDataHandler` / `ApacheDubboProxyService`) intentionally 
map different source fields (`upstreamUrl` vs `registry`), as called out as a 
secondary note in the issue, and are left unchanged.
   
   ## Tests
   
   New/extended, all passing together with the existing suites (259 tests 
across the four modules):
   
   - `AbstractDiscoveryUpstreamDataHandlerTest`: null handling, gray split, 
submit and remove flow.
   - `UpstreamPropsTest`: defaults, overrides and full-map exposure.
   - `WebSocketUpstreamDataHandlerTest`: new coverage for the websocket handler 
(handler, props, remove, plugin name).
   - `GrpcDiscoveryUpstreamDataHandlerTest`: added the upstream data path 
(cache + client init + props).
   - `DivideUpstreamDataHandlerTest` (existing) unchanged and green.
   
   Checkstyle passes for all four modules.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to