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 }
Kazv::headFailureCancelledErrorMsg
const std::string headFailureCancelledErrorMsg
Definition: jobinterface.hpp:17
Kazv::JobInterface::setInterval
virtual void setInterval(std::function< void()> func, int ms, std::optional< std::string > timerId=std::nullopt)=0
Kazv::headFailureCancelledStatusCode
const int headFailureCancelledStatusCode
Definition: jobinterface.hpp:18
Kazv
Definition: location.hpp:10
Kazv::JobInterface::~JobInterface
virtual ~JobInterface()=default
Kazv::JobInterface::submit
virtual void submit(BaseJob job, std::function< void(Response)> callback)=0
makes an async fetch.
Kazv::JobInterface::cancel
virtual void cancel(std::string timerId)=0
cancels all pending timers with timerId
Kazv::headFailureCancelledErrorCode
const std::string headFailureCancelledErrorCode
Definition: jobinterface.hpp:16
basejob.hpp
Kazv::JobInterface
Definition: jobinterface.hpp:20
Kazv::BaseJob
Definition: basejob.hpp:76
libkazv-config.hpp
Kazv::JobInterface::async
virtual void async(std::function< void()> func)=0
Kazv::JobInterface::setTimeout
virtual void setTimeout(std::function< void()> func, int ms, std::optional< std::string > timerId=std::nullopt)=0
Kazv::Response
Definition: basejob.hpp:50