Package com.vaadin.copilot.ide
Class IDEHeartbeatScheduler
java.lang.Object
com.vaadin.copilot.ide.IDEHeartbeatScheduler
A scheduler implementation that sends a request to IDE plugin in an interval
and shares the response with consumers.
Scheduler won't be created in the following conditions:
- When plugin is not active
- When plugin does not support
CopilotIDEPlugin.Commands.HEARTBEAT
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddConsumer(Consumer<IDEHeartbeatResponse> consumer) Saves the consumer into a set so that gets heartbeat responses from the IDEstatic IDEHeartbeatSchedulerGets the singleton instance ofIDEHeartbeatScheduler.voidStarts scheduler if not started.
-
Method Details
-
getInstance
Gets the singleton instance ofIDEHeartbeatScheduler.This method is synchronized to ensure thread-safety
- Returns:
- the instance
-
startIfNotStarted
public void startIfNotStarted()Starts scheduler if not started. This method considers state of IDE Plugin activation, also works only if IDE Plugin supports HEARTBEAT command. Once it is started, an internal flag is set so it cannot be started again. This method is synchronized to ensure thread-safety -
addConsumer
Saves the consumer into a set so that gets heartbeat responses from the IDE
-