$ show DerekYRC/mini-spring-cloud
mini-spring-cloud is an educational, simplified reimplementation of core Spring Cloud components, designed to help developers understand the underlying principles of service registration, discovery, client-side load balancing, declarative HTTP clients (Feign), and API gateway (Zuul). The codebase implements a custom lightweight registry called 'Tutu' and integrates with Netflix Ribbon, OpenFeign, and Netflix Zuul libraries. It follows Spring Cloud Commons abstractions and uses Spring Boot auto-configuration. The project is not intended for production use; it serves as a learning resource with minimal error handling, incomplete feature coverage (e.g., only POST mapping support in Feign contract), and no comprehensive test suite. The architecture is modular with separate Maven modules for each concern, and the code is clean and well-commented in Chinese. However, dependencies are somewhat outdated (Spring Cloud 2021.0.1, Ribbon 2.3.0, Zuul 1.3.1) and the project has not seen recent updates.
The LLM identified 3 files worth highlighting for reuse:
A decorator for Feign's Client interface that adds client-side load balancing using Spring Cloud's LoadBalancerClient. It intercepts Feign requests, resolves the service name from the URL, selects a service instance via the load balancer, reconstructs the URI, and delegates to the underlying Feign client. This component is cleanly separated and could be reused in any Feign-based project that has a LoadBalancerClient implementation.
A minimal implementation of Feign's Contract interface that supports Spring MVC annotations (specifically @PostMapping). It demonstrates how to parse method-level annotations and map them to Feign's MethodMetadata. While incomplete (only handles POST), the pattern is extensible and can serve as a starting point for building a custom Feign contract that supports additional Spring MVC annotations.
An ImportBeanDefinitionRegistrar that processes the @RibbonClients annotation to register RibbonClientSpecification beans. It extracts the defaultConfiguration attribute and creates bean definitions for each specification. This pattern is reusable for any custom annotation that needs to register named configuration classes for per-client customization, following the same approach used by Spring Cloud for Ribbon and Feign.