82: Remove lifecycle operations from the TickerService API
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user