82: Remove lifecycle operations from the TickerService API

This commit is contained in:
2026-09-03 20:34:49 +02:00
parent 461044a998
commit ddbf6f047d
11 changed files with 155 additions and 34 deletions
@@ -6,21 +6,13 @@ import org.jetbrains.annotations.NotNull;
/**
* Provides price observations for trading pairs.
*
* <p>The service contract contains only operations for ordinary consumers.
* The Hub owns startup through the implementation's separate
* {@code NenjimProcess} view.</p>
*/
public interface TickerService extends NenjimComponent {
/**
* Starts the ticker service.
*
* @throws IllegalStateException if the service cannot be started
*/
void start();
/**
* Stops every source started by this service.
*/
void stop();
/**
* Returns the latest available price observation for a trading pair.
*
@@ -39,6 +39,11 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Reference Ticker implementation whose domain API is exposed through
* {@link TickerService} and whose startup is owned by the Hub through
* {@link NenjimProcess}.
*/
public final class TickerServiceImpl implements
TickerService,
PriceSink,
@@ -88,24 +93,6 @@ public final class TickerServiceImpl implements
}
}
@Override
public synchronized void stop() {
if (state == LifecycleState.NEW || state == LifecycleState.STOPPED) {
return;
}
if (state != LifecycleState.STARTED) {
throw new IllegalStateException("Ticker service cannot stop while in state " + state);
}
state = LifecycleState.STOPPING;
RuntimeException failure = stopStartedSources();
resetStoppedState();
if (failure != null) {
throw failure;
}
}
@Override
public synchronized @NotNull PriceObservation getLatestPrice(
@NotNull TradingPair tradingPair