RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
AbstractJobStatusWatcher.hpp
1 /*
2  * AbstractJobStatusWatcher.hpp
3  *
4  * Copyright (C) 2020 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant to the terms of a commercial license agreement
7  * with RStudio, then this program is licensed to you under the following terms:
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
10  * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
11  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  */
23 
24 #ifndef LAUNCHER_PLUGINS_ABSTRACT_JOB_STATUS_WATCHER_HPP
25 #define LAUNCHER_PLUGINS_ABSTRACT_JOB_STATUS_WATCHER_HPP
26 
27 #include <Noncopyable.hpp>
28 
29 #include <PImpl.hpp>
30 #include <api/Job.hpp>
31 #include <jobs/AbstractJobRepository.hpp>
32 #include <jobs/JobStatusNotifier.hpp>
33 #include <system/DateTime.hpp>
34 
35 namespace rstudio {
36 namespace launcher_plugins {
37 namespace jobs {
38 
43 {
44 public:
48  virtual ~AbstractJobStatusWatcher() = default;
49 
53  virtual Error start() = 0;
54 
58  virtual void stop() = 0;
59 
60 protected:
67  AbstractJobStatusWatcher(JobRepositoryPtr in_jobRepository, JobStatusNotifierPtr in_jobStatusNotifier);
68 
82  const std::string& in_jobId,
83  api::Job::State in_newStatus,
84  const std::string& in_statusMessage = "",
85  const system::DateTime& in_invocationTime = system::DateTime());
86 
87 private:
96  virtual Error getJobDetails(const std::string& in_jobId, api::JobPtr& out_job) const = 0;
97 
98  // The private implementation of AbstractJobStatusWatcher.
99  PRIVATE_IMPL(m_baseImpl);
100 };
101 
102 } // namespace jobs
103 } // namespace launcher_plugins
104 } // namespace rstudio
105 
106 #endif
rstudio::launcher_plugins::jobs::AbstractJobStatusWatcher::AbstractJobStatusWatcher
AbstractJobStatusWatcher(JobRepositoryPtr in_jobRepository, JobStatusNotifierPtr in_jobStatusNotifier)
Constructor.
rstudio::launcher_plugins::jobs::AbstractJobStatusWatcher::updateJobStatus
Error updateJobStatus(const std::string &in_jobId, api::Job::State in_newStatus, const std::string &in_statusMessage="", const system::DateTime &in_invocationTime=system::DateTime())
Updates the job status for the specified job.
rstudio::launcher_plugins::jobs::AbstractJobStatusWatcher
Manages posting job status updates to the notifier.
Definition: AbstractJobStatusWatcher.hpp:42
rstudio::launcher_plugins::api::Job::State
State
Definition: Job.hpp:153
rstudio::launcher_plugins::system::DateTime
Class which represents a date and time in UTC.
Definition: DateTime.hpp:244
rstudio::launcher_plugins::Error
Class which represents an error.
Definition: Error.hpp:174
rstudio::launcher_plugins::jobs::AbstractJobStatusWatcher::start
virtual Error start()=0
Starts the job status watcher.
rstudio::launcher_plugins::jobs::AbstractJobStatusWatcher::stop
virtual void stop()=0
Stops the job status watcher.
rstudio::launcher_plugins::Noncopyable
Class which can be inherited from to disallow copying of its child classes.
Definition: Noncopyable.hpp:34
rstudio::launcher_plugins::jobs::AbstractJobStatusWatcher::~AbstractJobStatusWatcher
virtual ~AbstractJobStatusWatcher()=default
Virtual destructor for inheritance.