// ######################## Make ########################
@Override
public void make(final Message message) {
final Instrument instrument = message.getInstrument();
if (!isValid(instrument)) {
return;
}
MarketDo market = marketMap.get(instrument.id());
final boolean valid = isValid(market);
if(!valid) {
register(instrument);
market = marketMap.get(instrument.id());
}
market.runSafe(safeMake, message);
/* Below is a hack to keep the subscriptions updated */
/* If a new market is created, a new subscription is made,
* but it needs the State enum from market which should
* get set on the first market snapshot, which is why
* this comes after the above safeRun update of the message */
/* If the state hasn't been set, this will mark it as Delayed,
* and we're not updating */
Subscription.Lense lense;
if(market.get(MarketField.STATE).contains(
MarketStateEntry.IS_PUBLISH_REALTIME)) {
lense = Subscription.Lense.REALTIME;
} else if(market.get(MarketField.STATE).contains(
MarketStateEntry.IS_PUBLISH_DELAYED)) {
lense = Subscription.Lense.DELAYED;
} else {
lense = Subscription.Lense.NULL;
}
if(!valid) {
log.debug("Adding Subscription to map for {}", instrument.symbol());
varSubs.put(instrument.id(), new VarSubscription(instrument, lense));
defSubs.put(instrument.id(), varSubs.get(instrument.id()));
}
varSubs.get(instrument.id()).setLense(lense);
}