Skip to main content

SureInk Discovery Server (sureink-discovery-server)

Overview

The sureink-discovery-server is the service discovery component for the SureInk Platform. It utilizes Netflix Eureka to allow microservices within the platform to register themselves and discover the network locations (IP addresses and ports) of other registered services. This enables dynamic service-to-service communication in a microservices architecture.

Technology Stack

  • Core Framework: Java, Spring Boot
  • Service Discovery: Spring Cloud Netflix Eureka Server (spring-cloud-starter-netflix-eureka-server)
  • Build System: Apache Maven

Key Functionalities

  • Service Registration: Allows other SureInk microservices (Eureka clients) to register their presence, providing metadata such as service name, host, and port.
  • Service Discovery: Provides an API for registered services to query the registry and find instances of other services they need to communicate with.
  • Instance Health Checking: Eureka clients send heartbeats to the server. If heartbeats are missed, the server can de-register an instance, assuming it's no longer available.
  • Eureka Dashboard: Provides a web UI (typically accessible at the server's root URL, e.g., http://localhost:8761/) that displays all registered service instances and their status.

Project Structure

  • pom.xml: Defines the project dependencies, primarily spring-cloud-starter-netflix-eureka-server.
  • src/main/java/com/sureink/discoveryserver/DiscoveryServerApplication.java: The main Spring Boot application class, annotated with @SpringBootApplication and @EnableEurekaServer to activate Eureka server functionality.
  • src/main/resources/: This directory currently does not contain an application.properties or application.yml file. The server will run with default settings or rely on externally provided configuration.

Configuration

While no local application.properties or application.yml file is present in the source code, a Eureka server typically requires configuration. These properties can be set via command-line arguments, environment variables, or a configuration server.

Common properties for a standalone Eureka server:

  • server.port: The port on which the Eureka server will listen.

    • Default: 8761
    • Example: server.port=8761
  • eureka.client.register-with-eureka: Whether this server should register itself with another Eureka server (for peer awareness in a cluster). For a standalone server, this should be false.

    • Default: true
    • Example for standalone: eureka.client.register-with-eureka=false
  • eureka.client.fetch-registry: Whether this server should fetch the registry information from another Eureka server. For a standalone server, this should be false.

    • Default: true
    • Example for standalone: eureka.client.fetch-registry=false
  • eureka.instance.hostname: The hostname of the Eureka server instance.

    • Example: eureka.instance.hostname=localhost

For a clustered setup, these eureka.client properties would be configured to point to other peer Eureka servers.

Prerequisites

  • JDK 11 or later
  • Apache Maven

Build Instructions

cd path/to/sureink-discovery-server
mvn clean install

Running the Application

java -jar target/sureink-discovery-server-1.0-SNAPSHOT.jar

You can also provide configuration properties via the command line:

java -jar target/sureink-discovery-server-1.0-SNAPSHOT.jar \
--server.port=8761 \
--eureka.client.register-with-eureka=false \
--eureka.client.fetch-registry=false

Once started, the Eureka dashboard should be accessible at http://<hostname>:<port>/ (e.g., http://localhost:8761/).

Dockerization

The pom.xml includes profiles for building Docker images using docker-maven-plugin, indicating that this service is intended to be containerized. Refer to the Dockerfile (typically in src/main/docker/) and Maven profiles for specific Docker build instructions.