Skip to content

io microsphere spring cloud client service registry InMemoryServiceRegistry

github-actions[bot] edited this page Jun 10, 2026 · 5 revisions

InMemoryServiceRegistry

Type: Class | Module: microsphere-spring-cloud-commons | Package: io.microsphere.spring.cloud.client.service.registry | Since: 1.0.0

Source: microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/service/registry/InMemoryServiceRegistry.java

Overview

In-Memory ServiceRegistry

Declaration

public class InMemoryServiceRegistry implements ServiceRegistry

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.18-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Method Examples

register

InMemoryServiceRegistry registry = new InMemoryServiceRegistry();
Registration registration = createRegistration();
registry.register(registration);

deregister

InMemoryServiceRegistry registry = new InMemoryServiceRegistry();
Registration registration = createRegistration();
registry.register(registration);
registry.deregister(registration);

close

InMemoryServiceRegistry registry = new InMemoryServiceRegistry();
registry.register(registration);
registry.close();

setStatus

InMemoryServiceRegistry registry = new InMemoryServiceRegistry();
registry.register(registration);
registry.setStatus(registration, "UP");

getStatus

InMemoryServiceRegistry registry = new InMemoryServiceRegistry();
registry.register(registration);
registry.setStatus(registration, "UP");
Object status = registry.getStatus(registration); // "UP"

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-cloud-commons</artifactId>
    <version>${microsphere-spring-cloud.version}</version>
</dependency>

Tip: Use the BOM (microsphere-spring-cloud-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.spring.cloud.client.service.registry.InMemoryServiceRegistry;

API Reference

Public Methods

Method Description
register Registers the given Registration instance in the in-memory storage,
deregister Removes the given Registration instance from the in-memory storage.
close Closes this registry by clearing all stored Registration instances.
setStatus Sets the status of the given Registration by storing it in
getStatus Retrieves the status of the given Registration from its metadata.

Method Details

register

public void register(Registration registration)

Registers the given Registration instance in the in-memory storage, keyed by its instance ID.

Example Usage:

`InMemoryServiceRegistry registry = new InMemoryServiceRegistry();
Registration registration = createRegistration();
registry.register(registration);
`

deregister

public void deregister(Registration registration)

Removes the given Registration instance from the in-memory storage.

Example Usage:

`InMemoryServiceRegistry registry = new InMemoryServiceRegistry();
Registration registration = createRegistration();
registry.register(registration);
registry.deregister(registration);
`

close

public void close()

Closes this registry by clearing all stored Registration instances.

Example Usage:

`InMemoryServiceRegistry registry = new InMemoryServiceRegistry();
registry.register(registration);
registry.close();
`

setStatus

public void setStatus(Registration registration, String status)

Sets the status of the given Registration by storing it in the registration's metadata under the _status_ key.

Example Usage:

`InMemoryServiceRegistry registry = new InMemoryServiceRegistry();
registry.register(registration);
registry.setStatus(registration, "UP");
`

getStatus

public Object getStatus(Registration registration)

Retrieves the status of the given Registration from its metadata.

Example Usage:

`InMemoryServiceRegistry registry = new InMemoryServiceRegistry();
registry.register(registration);
registry.setStatus(registration, "UP");
Object status = registry.getStatus(registration); // "UP"
`

This documentation was auto-generated from the source code of microsphere-spring-cloud.

Home

spring-cloud-commons

spring-cloud-openfeign

Clone this wiki locally