@Test public void subscribeShouldUpdateMetrics() { subscriptions.subscribe("1", subscriberCallback); verify(metrics).updateConnectedValidators(1); subscriptions.subscribe("2", subscriberCallback); verify(metrics).updateConnectedValidators(2); }
SubscriptionStatus subscribe(String id, Consumer<BeaconChainEvent> sendEvent) { synchronized (this) { if (subscriptions.size() >= maxSubscribers) { return SubscriptionStatus.maxSubscribers(); } else { subscriptions.put(id, sendEvent); updateSubscribedValidatorsMetric(); return SubscriptionStatus.success(); } } }
RemoteValidatorSubscriptions implements BeaconChainEventsListener { SubscriptionStatus subscribe(String id, Consumer<BeaconChainEvent> sendEvent) { synchronized (this) { if (subscriptions.size() >= maxSubscribers) { return SubscriptionStatus.maxSubscribers(); } else { subscriptions.put(id, sendEvent); updateSubscribedValidatorsMetric(); return SubscriptionStatus.success(); } } } }
RemoteValidatorSubscriptions implements BeaconChainEventsListener { SubscriptionStatus subscribe(String id, Consumer<BeaconChainEvent> sendEvent) { synchronized (this) { if (subscriptions.size() >= maxSubscribers) { return SubscriptionStatus.maxSubscribers(); } else { subscriptions.put(id, sendEvent); updateSubscribedValidatorsMetric(); return SubscriptionStatus.success(); } } } RemoteValidatorSubscriptions(
      final GlobalConfiguration configuration, final RemoteValidatorMetrics metrics); }
RemoteValidatorSubscriptions implements BeaconChainEventsListener { SubscriptionStatus subscribe(String id, Consumer<BeaconChainEvent> sendEvent) { synchronized (this) { if (subscriptions.size() >= maxSubscribers) { return SubscriptionStatus.maxSubscribers(); } else { subscriptions.put(id, sendEvent); updateSubscribedValidatorsMetric(); return SubscriptionStatus.success(); } } } RemoteValidatorSubscriptions(
      final GlobalConfiguration configuration, final RemoteValidatorMetrics metrics); @Override void onEvent(final BeaconChainEvent event); }
RemoteValidatorSubscriptions implements BeaconChainEventsListener { SubscriptionStatus subscribe(String id, Consumer<BeaconChainEvent> sendEvent) { synchronized (this) { if (subscriptions.size() >= maxSubscribers) { return SubscriptionStatus.maxSubscribers(); } else { subscriptions.put(id, sendEvent); updateSubscribedValidatorsMetric(); return SubscriptionStatus.success(); } } } RemoteValidatorSubscriptions(
      final GlobalConfiguration configuration, final RemoteValidatorMetrics metrics); @Override void onEvent(final BeaconChainEvent event);  }