메이커링크
MSA 서비스 디스커버리: Eureka, Consul, Zookeeper 연동 및 자동 등록 프롬프트
MSA 환경에서 서비스 간 통신을 위한 서비스 디스커버리 패턴을 Cursor에 적용하는 방법을 안내합니다. Eureka, Consul, Zookeeper 기반의 서비스 자동 등록 및 조회에 대한 구체적인 코드와 설정 예시를 제공합니다.
You are an expert microservices architect and a seasoned MakerLink user specializing in distributed systems. Your task is to generate a comprehensive, copy-paste ready "Command/Prompt Recipe" for Cursor IDE to implement effective service discovery patterns in a Microservices Architecture (MSA).
Goal
Implement robust service discovery mechanisms for microservices using common patterns like client-side discovery and server-side discovery, leveraging popular tools such as Netflix Eureka, HashiCorp Consul, or Apache ZooKeeper. This recipe focuses on automating service registration and discovery.
Target Platform
Cursor IDE
Recipe Type
Direct Execution / Copy-Paste
Core Concepts
Microservices Architecture (MSA) relies on breaking down applications into smaller, independent services. Service discovery is crucial for these services to find and communicate with each other dynamically as instances scale up or down, or move across different network locations.
1. Client-Side Discovery
In this pattern, the client (a microservice) is responsible for querying the service registry to get the network locations of available service instances. It then chooses one and makes a direct request.
- Service Registry: A database of available service instances and their network locations.
- Service Registration: When a service instance starts, it registers itself with the service registry.
- Service Discovery: When a client needs to call a service, it queries the registry to find available instances, selects one (e.g., using a load-balancing algorithm), and makes the call.
- Health Checks: The registry monitors the health of registered instances. Unhealthy instances are removed.
2. Server-Side Discovery
Here, the client makes a request to a router or load balancer, which is aware of the service registry. The router/load balancer queries the registry, selects a service instance, and forwards the request.
- Benefits: Simpler client implementation, as the client doesn't need discovery logic.
- Components: Service registry, service registration, load balancer/router, health checks.
Implementation Recipes (Cursor Integration)
Recipe A: Eureka Service Discovery Integration (Java/Spring Boot Example)
Scenario: You have a user-service and an order-service. Both need to discover each other. You also need a Eureka Server to act as the registry.
1. Set up Eureka Server:
- Create a new Spring Boot project (e.g.,
eureka-server) using Spring Initializr (start.spring.io). - Add dependencies:
Eureka Server. - In
EurekaServerApplication.java, add@EnableEurekaServerannotation. - In
application.properties(orapplication.yml):server.port=8761 eureka.client.register-with-eureka=false eureka.client.fetch-registry=false eureka.instance.hostname=localhost - Run the
eureka-serverapplication.
**2. Configure user-service (Client):
- Add dependencies:
Eureka Discovery Client. - In
application.properties(orapplication.yml):spring.application.name=user-service server.port=8080 eureka.client.service-url.defaultZone=http://localhost:8761/eureka/ - Add
@EnableEurekaClientto your main application class.
**3. Configure order-service (Client):
- Add dependencies:
Eureka Discovery Client. - In
application.properties(orapplication.yml):spring.application.name=order-service server.port=8081 eureka.client.service-url.defaultZone=http://localhost:8761/eureka/ - Add
@EnableEurekaClientto your main application class.
4. Service-to-Service Communication (within order-service calling user-service):
- Inject
RestTemplateorWebClientand use the service name (user-service) as the hostname.import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annot
메이커링크 에이전트
이 레시피, 직접 따라 하지 말고 맡겨 보세요
휴대폰에서 한 줄로 지시하면 메이커링크 에이전트가 내 PC의 Cursor · Claude Code로 그대로 실행합니다.
함께 보면 좋은 레시피
AI 레시피
HTTP/3 프로토콜 이해 및 성능 개선을 위한 AI 프롬프트 레시피
HTTP/3의 기본 원리와 QUIC 프로토콜의 장점을 이해하고, 웹 애플리케이션의 성능을 최적화하는 방법을 AI 개발 도구를 활용하여 학습합니다.
AI 레시피
ORM 작동 원리 및 성능 최적화 기법 가이드
ORM의 핵심 원리를 이해하고, 실제 개발에서 발생할 수 있는 성능 병목 현상을 진단하며, 이를 해결하기 위한 구체적인 최적화 기법을 학습합니다.
터미널 레시피
Redis CLI로 데이터 캐싱 확인 및 Pub/Sub 메시지 전송/구독
Redis CLI를 사용하여 특정 키의 캐시 데이터를 확인하고, 발행/구독 패턴으로 메시지를 실시간으로 주고받는 방법을 안내합니다. 실시간 데이터 동기화 및 캐시 검증에 유용합니다.
터미널 레시피
PowerShell로 모든 프로세스 정보 확인 및 특정 프로세스 강제 종료
실행 중인 모든 프로세스의 상세 정보(이름, ID, 메모리 사용량 등)를 확인하고, 원하는 프로세스를 이름이나 ID로 찾아 강제 종료할 때 유용합니다.
아이디어
퇴근 후 직장인을 위한 망각 방지 AI 자격증 튜터
퇴근 후 시간이 부족한 직장인을 위해 지난 학습 맥락과 취약 개념을 기억하고 시험 출제 기준에 맞춘 복습 퀴즈를 내주는 AI 튜터 웹앱입니다.
아이디어
내 부자재로 바로 만드는 공예 도안 비서, 비즈넷블라인드
서랍 속 남은 비즈와 부자재 재고를 등록하면 중복 구매 없이 지금 당장 완성할 수 있는 DIY 공예 도안을 찾아주는 웹 서비스입니다.