libkazv
jobinterface.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of libkazv.
3  * SPDX-FileCopyrightText: 2020 Tusooa Zhu
4  * SPDX-License-Identifier: AGPL-3.0-or-later
5  */
6 
7 
8 #pragma once
9 #include "libkazv-config.hpp"
10 #include <functional>
11 
12 #include "basejob.hpp"
13 
14 namespace Kazv
15 {
16  inline const std::string headFailureCancelledErrorCode{"MOE_KAZV_MXC_HEAD_FAILURE_CANCELLED"};
17  inline const std::string headFailureCancelledErrorMsg{"This job is cancelled because one before it failed."};
18  inline const int headFailureCancelledStatusCode{490};
19 
20  struct JobInterface
21  {
22  virtual ~JobInterface() = default;
23  virtual void async(std::function<void()> func) = 0;
24  virtual void setTimeout(std::function<void()> func, int ms,
25  std::optional<std::string> timerId = std::nullopt) = 0;
26  virtual void setInterval(std::function<void()> func, int ms,
27  std::optional<std::string> timerId = std::nullopt) = 0;
28 
30  virtual void cancel(std::string timerId) = 0;
31 
38  virtual void submit(BaseJob job, std::function<void(Response)> callback) = 0;
39  };
40 
41 }
Definition: basejob.hpp:77
Definition: location.hpp:10
const std::string headFailureCancelledErrorMsg
Definition: jobinterface.hpp:17
const std::string headFailureCancelledErrorCode
Definition: jobinterface.hpp:16
const int headFailureCancelledStatusCode
Definition: jobinterface.hpp:18
Definition: jobinterface.hpp:21
virtual void async(std::function< void()> func)=0
virtual ~JobInterface()=default
virtual void submit(BaseJob job, std::function< void(Response)> callback)=0
makes an async fetch.
virtual void setTimeout(std::function< void()> func, int ms, std::optional< std::string > timerId=std::nullopt)=0
virtual void setInterval(std::function< void()> func, int ms, std::optional< std::string > timerId=std::nullopt)=0
virtual void cancel(std::string timerId)=0
cancels all pending timers with timerId
Definition: basejob.hpp:50