Interface HealthTrackerRegistry
- All Known Implementing Classes:
HealthTrackerRegistryImpl
public interface HealthTrackerRegistry
A registry for the
HealthTracker
health trackers created per ProjectSubscriptionName
.- Since:
- 2.0.6
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(com.google.cloud.pubsub.v1.Subscriber subscriber) Attaches a listener to a Pub/Sub subscriber provided aHealthTracker
is registered for that subscription.Retrieve all the health trackers registered.boolean
isTracked
(com.google.pubsub.v1.ProjectSubscriptionName projectSubscriptionName) Check if aProjectSubscriptionName
has aHealthTracker
registered.void
processedMessage
(com.google.pubsub.v1.ProjectSubscriptionName projectSubscriptionName) Propagate that a message has been processed to the correspondingHealthTracker
if registered.registerTracker
(com.google.pubsub.v1.ProjectSubscriptionName projectSubscriptionName) Create a tracker for givenProjectSubscriptionName
and add tracker to registry.registerTracker
(String subscriptionName) Create a tracker for given subscription name and add tracker to registry.default com.google.cloud.pubsub.v1.MessageReceiver
wrap
(com.google.pubsub.v1.ProjectSubscriptionName subscriptionName, com.google.cloud.pubsub.v1.MessageReceiver messageReceiver) Wrap a message receiver for aProjectSubscriptionName
.
-
Method Details
-
registerTracker
Create a tracker for given subscription name and add tracker to registry.- Parameters:
subscriptionName
- the subscription name to create aProjectSubscriptionName
using the default project-Id.- Returns:
- the
HealthTracker
that has been created and registered.
-
registerTracker
Create a tracker for givenProjectSubscriptionName
and add tracker to registry.- Parameters:
projectSubscriptionName
- the full subscription name- Returns:
- the
HealthTracker
that has been created and registered.
-
isTracked
boolean isTracked(com.google.pubsub.v1.ProjectSubscriptionName projectSubscriptionName) Check if aProjectSubscriptionName
has aHealthTracker
registered.- Parameters:
projectSubscriptionName
- the full subscription name.- Returns:
- true if
HealthTracker
is registered.
-
wrap
default com.google.cloud.pubsub.v1.MessageReceiver wrap(com.google.pubsub.v1.ProjectSubscriptionName subscriptionName, com.google.cloud.pubsub.v1.MessageReceiver messageReceiver) Wrap a message receiver for aProjectSubscriptionName
. AHealthTracker
will be created and registered. On a new message received the registeredHealthTracker
will record its processing.- Parameters:
subscriptionName
- the fullProjectSubscriptionName
name to monitor.messageReceiver
- theMessageReceiver
to wrap.- Returns:
- messageReceiver the wrapped
MessageReceiver
.
-
processedMessage
void processedMessage(com.google.pubsub.v1.ProjectSubscriptionName projectSubscriptionName) Propagate that a message has been processed to the correspondingHealthTracker
if registered.- Parameters:
projectSubscriptionName
- the fullProjectSubscriptionName
name to monitor.
-
addListener
void addListener(com.google.cloud.pubsub.v1.Subscriber subscriber) Attaches a listener to a Pub/Sub subscriber provided aHealthTracker
is registered for that subscription. On subscriber termination, the correspondingHealthTracker
shall be removed from the registry.- Parameters:
subscriber
- the subscriber to attach a listener.
-
healthTrackers
Collection<HealthTracker> healthTrackers()Retrieve all the health trackers registered.- Returns:
- all known health trackers
-