Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add client interface. #16

Merged
merged 88 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
6ffea6e
feat: Add client code structure and interface for Data, Future and ex…
sitaowang1998 Oct 31, 2024
94af15b
feat: Split client into two libraries and add interface
sitaowang1998 Oct 31, 2024
f69523a
fix: Add boost library for spider_client_lib
sitaowang1998 Nov 1, 2024
ccf6cc8
style: Improve code style for data based on pr comments
sitaowang1998 Nov 1, 2024
5e26f58
fix: Add absl as public library for core
sitaowang1998 Nov 1, 2024
020093c
style: Improve code style for client interface based on pr reviea pri…
sitaowang1998 Nov 1, 2024
ee222f0
fix: Try fix clang-tidy find nout found
sitaowang1998 Nov 1, 2024
1b0ccac
docs: Add quick start doc
sitaowang1998 Nov 1, 2024
b3a2e1e
style: Change markdown headings to sentence style and hard wrap markd…
sitaowang1998 Nov 3, 2024
ec8f500
docs: Update doc according to pr comments
sitaowang1998 Nov 3, 2024
5dc12cb
docs: Remove the worker note section and put the content in run task …
sitaowang1998 Nov 3, 2024
0d59c62
docs: Return a Job instead of Future for run and support user to pass…
sitaowang1998 Nov 5, 2024
4cd6233
Merge branch 'main' into interface
sitaowang1998 Nov 6, 2024
fec5e73
Change future to job
sitaowang1998 Nov 14, 2024
a5e799b
Change task to context
sitaowang1998 Nov 14, 2024
1b15b5d
Remove TaskGraph::run to simplify interface
sitaowang1998 Nov 16, 2024
98104f1
Add separate key-value store interface
sitaowang1998 Nov 16, 2024
cb369fd
Edit some docstrings.
kirkrodrigues Nov 19, 2024
b4a6f36
Fix include guard
sitaowang1998 Nov 19, 2024
f3de2ca
Merge branch 'main' into interface
sitaowang1998 Nov 19, 2024
70547ae
Add serialzable concept
sitaowang1998 Nov 20, 2024
525311c
Merge remote-tracking branch 'origin/interface' into interface
sitaowang1998 Nov 20, 2024
c776376
Fix clang-tidy
sitaowang1998 Nov 20, 2024
49c571e
Fix typo
sitaowang1998 Nov 20, 2024
43d7e16
Fix clang-tidy
sitaowang1998 Nov 20, 2024
5e8e1dd
Remove macOS build
sitaowang1998 Nov 20, 2024
fe23c3c
Change driver constructor
sitaowang1998 Nov 20, 2024
064edd8
Add exception to interface
sitaowang1998 Nov 20, 2024
e7c5240
Change run to start
sitaowang1998 Nov 20, 2024
b0b414e
Add get jobs to driver
sitaowang1998 Nov 20, 2024
97761e1
Add get jobs in context
sitaowang1998 Nov 20, 2024
91d36f2
Update doc with new interface
sitaowang1998 Nov 20, 2024
84c2f41
Fix clang-tidy
sitaowang1998 Nov 20, 2024
f7ab013
Refactor Context.hpp.
kirkrodrigues Nov 21, 2024
302e68a
style: Fix header guard name
sitaowang1998 Nov 21, 2024
a2dc8bc
style: Rename Context to TaskContext
sitaowang1998 Nov 21, 2024
046e740
style: Add missing class docstring
sitaowang1998 Nov 21, 2024
92d6489
feat: Add concepts for task argument
sitaowang1998 Nov 21, 2024
d27f042
Refactor Context.hpp.
kirkrodrigues Nov 21, 2024
2b49746
feat: Change the arguments from Serializable to TaskArgument
sitaowang1998 Nov 21, 2024
c4ee015
style: Update docstring for Driver
sitaowang1998 Nov 21, 2024
0cc231b
style: Update docstring for Data and Job
sitaowang1998 Nov 21, 2024
069a7a7
style: Update clang-format for library headers
sitaowang1998 Nov 21, 2024
9069030
style: Clean up unused headers and Change TaskGraph template
sitaowang1998 Nov 21, 2024
0fe063f
doc: Update quick start guide
sitaowang1998 Nov 21, 2024
e089107
style: Fix clang-tidy
sitaowang1998 Nov 21, 2024
159aa08
Rename TaskArgument to TaskIo
sitaowang1998 Nov 21, 2024
8e035b7
feat: Add Runnable concept and TaskFunction type
sitaowang1998 Nov 21, 2024
9d90c37
refactor: Rename insert_kv and get_kv to kv_store_insert and kv_store…
sitaowang1998 Nov 21, 2024
8de26ec
fix: Fix the template instantiation of TaskFunction
sitaowang1998 Nov 22, 2024
b9bfcdd
style: Fix clang-tidy
sitaowang1998 Nov 22, 2024
351c8b5
docs: Move cluster setup after run task and change all mentions of da…
sitaowang1998 Nov 22, 2024
7dae8d4
docs: Add task graph to group task example
sitaowang1998 Nov 22, 2024
5d15b22
Refactor Data.hpp
kirkrodrigues Nov 25, 2024
1588b51
Refactor Driver.hpp
kirkrodrigues Nov 25, 2024
1e1e41d
Refactor Exception.hpp
kirkrodrigues Nov 25, 2024
c0a6e6f
Refactor Job.hpp.
kirkrodrigues Nov 25, 2024
99c5935
Refactor TaskContext.hpp.
kirkrodrigues Nov 25, 2024
80f314a
Refactor TaskGraph.hpp.
kirkrodrigues Nov 25, 2024
7796e15
Refactor Concepts.hpp.
kirkrodrigues Nov 25, 2024
036dd51
Add absl to libraray list and sort library list
sitaowang1998 Nov 26, 2024
8affa10
Rename template types to satisfy clang-tidy
sitaowang1998 Nov 26, 2024
77d2458
Change set_cleanup to set_cleanup_func
sitaowang1998 Nov 26, 2024
026b6f1
Change set_cleanup to set_cleanup_func
sitaowang1998 Nov 26, 2024
448f693
Change job state enum name and error docstring
sitaowang1998 Nov 26, 2024
769a708
Restruct all the concepts
sitaowang1998 Nov 26, 2024
3555d2e
Add todo for task registration with timeout
sitaowang1998 Nov 26, 2024
a0c5b3a
Fix circular dependency
sitaowang1998 Nov 26, 2024
e185bf3
Restruct quick start guide
sitaowang1998 Nov 26, 2024
f0d79e9
Fix clang-tidy
sitaowang1998 Nov 26, 2024
f444772
Remove all cpp files in client
sitaowang1998 Nov 26, 2024
530da78
Move driver id section after task restart
sitaowang1998 Nov 26, 2024
db21fe7
Add Job::cancel
sitaowang1998 Nov 28, 2024
165eb84
Fix typo
sitaowang1998 Nov 29, 2024
06de774
Fix clean up function signature
sitaowang1998 Nov 29, 2024
c7a07b1
Fix set_locality argument in docstring example
sitaowang1998 Nov 29, 2024
f8c623a
Add void return type for kv_store_insert
sitaowang1998 Nov 29, 2024
488eaa3
Add noreturn and void return type for TaskContext::abort
sitaowang1998 Nov 29, 2024
f0729d9
Fix some header guards.
kirkrodrigues Nov 29, 2024
4d2aa6c
Edit some docstrings and comments.
kirkrodrigues Nov 29, 2024
88ed638
Fix typo in Data docstring example.
kirkrodrigues Nov 29, 2024
bd55552
Add exception in docstring
sitaowang1998 Nov 29, 2024
9897995
Remove pImpl in interface
sitaowang1998 Nov 29, 2024
73eabef
Fix clang-tidy
sitaowang1998 Nov 29, 2024
85d2475
Fix exception what
sitaowang1998 Nov 29, 2024
61be939
Fix docstring job state name
sitaowang1998 Nov 29, 2024
5bffeee
Refactor exceptions.
kirkrodrigues Nov 29, 2024
22f370d
Remove quick start guide
sitaowang1998 Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/spider/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ IncludeCategories:
# Ex:
# - Regex: "<(fmt|spdlog)"
# Priority: 3
- Regex: "^<(clp)"
- Regex: "^<(absl|boost|catch2|fmt|mariadb|msgpack|spdlog)"
Priority: 3
# C system headers
- Regex: "^<.+\\.h>"
Expand Down
47 changes: 46 additions & 1 deletion src/spider/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,54 @@ target_link_libraries(
)
target_link_libraries(spider_core PRIVATE fmt::fmt)

set(SPIDER_CLIENT_SHARED_SOURCES CACHE INTERNAL "spider client shared source files")

set(SPIDER_CLIENT_SHARED_HEADERS
client/Data.hpp
client/Driver.hpp
client/task.hpp
client/TaskContext.hpp
client/TaskGraph.hpp
client/type_utils.hpp
client/Exception.hpp
CACHE INTERNAL
"spider client shared header files"
)
Comment on lines +33 to +43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Standardize header file naming convention

The header file naming is inconsistent:

  • task.hpp uses lowercase
  • Other files use PascalCase (e.g., TaskGraph.hpp)

Please maintain consistent PascalCase for class header files.

-    client/task.hpp
+    client/Task.hpp
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
set(SPIDER_CLIENT_SHARED_HEADERS
client/Data.hpp
client/Driver.hpp
client/task.hpp
client/TaskContext.hpp
client/TaskGraph.hpp
client/type_utils.hpp
client/Exception.hpp
CACHE INTERNAL
"spider client shared header files"
)
set(SPIDER_CLIENT_SHARED_HEADERS
client/Data.hpp
client/Driver.hpp
client/Task.hpp
client/TaskContext.hpp
client/TaskGraph.hpp
client/type_utils.hpp
client/Exception.hpp
CACHE INTERNAL
"spider client shared header files"
)


add_library(spider_client_lib)
target_sources(spider_client_lib PRIVATE ${SPIDER_CLIENT_SHARED_SOURCES})
target_sources(spider_client_lib PUBLIC ${SPIDER_CLIENT_SHARED_HEADERS})
target_link_libraries(
spider_client_lib
PUBLIC
Boost::boost
absl::flat_hash_map
)

set(SPIDER_CLIENT_SOURCES CACHE INTERNAL "spider client source files")

set(SPIDER_CLIENT_HEADERS
client/spider.hpp
client/Job.hpp
CACHE INTERNAL
"spider client header files"
)

add_library(spider_client)
target_sources(spider_client PRIVATE ${SPIDER_CLIENT_SOURCES})
target_sources(spider_client PUBLIC ${SPIDER_CLIENT_HEADERS})
target_link_libraries(spider_client PRIVATE spider_core)
target_link_libraries(spider_client PUBLIC spider_client_lib)
add_library(spider::spider ALIAS spider_client)

set(SPIDER_WORKER_SOURCES worker/worker.cpp CACHE INTERNAL "spider worker source files")

add_executable(spider_worker)
target_sources(spider_worker PRIVATE ${SPIDER_WORKER_SOURCES})
target_link_libraries(spider_worker PRIVATE spider_core)
target_link_libraries(
spider_worker
PRIVATE
spider_core
spider_client_lib
)
add_executable(spider::worker ALIAS spider_worker)
82 changes: 82 additions & 0 deletions src/spider/client/Data.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#ifndef SPIDER_CLIENT_DATA_HPP
#define SPIDER_CLIENT_DATA_HPP

#include <functional>
#include <memory>
#include <string>
#include <vector>

#include "../core/Serializer.hpp"

kirkrodrigues marked this conversation as resolved.
Show resolved Hide resolved
namespace spider {
class DataImpl;

/**
* A representation of data stored on external storage. This class allows the user to define:
* - how the data should be cleaned up (garbage collected) once it is no longer referenced.
* - the locality of the data.
*
* Example:
* @code{.cpp}
* auto disk_file_data = spider::Data<std::string>::Builder()
* .set_locality({"node_address"}, true)
* .set_cleanup_func([](std::string const& path) { std::filesystem::remove(path); })
* .build("/path/of/file");
* @endcode
*
* @tparam T Type of the value.
*/
template <Serializable T>
class Data {
kirkrodrigues marked this conversation as resolved.
Show resolved Hide resolved
public:
/**
* @return The stored value.
*/
auto get() -> T;
Comment on lines +32 to +35
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding error handling to get()

The get() method might fail when accessing the underlying storage. Consider:

  1. Adding error handling using std::expected (C++23) or Result type
  2. Documenting potential failure scenarios


/**
* Sets the data's locality, indicated by the nodes that contain the data.
*
* @param nodes
* @param hard Whether the data is only accessible from the given nodes (i.e., the locality is a
* hard requirement).
*/
void set_locality(std::vector<std::string> const& nodes, bool hard);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We prefer to use std::span and std::string_view instead of const vectors or strings.
  • Why do we need this method compared to the one in the builder?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locality information might not be available at the time we create the data. For example, we create an associated data for HDFS files before we create the actual HDFS files and write to them so that Spider can gc the HDFS files on failure during write. However, we don't know the locality of the HDFS files before creating them, and thus we need a way to set locality on the fly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodes represents an array of addresses. I'm not sure if std::span or std::string_view is suitable for this case.


class Builder {
public:
/**
* Sets the data's locality, indicated by the nodes that contain the data.
*
* @param nodes
* @param hard Whether the data is only accessible from the given nodes (i.e., the locality
* is a hard requirement.
* @return self
*/
auto set_locality(std::vector<std::string> const& nodes, bool hard) -> Builder&;

/**
* Sets the cleanup function for the data. This function will be called when the data is no
* longer referenced.
*
* @param f
* @return self
*/
auto set_cleanup_func(std::function<void(T const&)> const& f) -> Builder&;

/**
* Builds the data object.
*
* @param t Value of the data
* @return The built object.
* @throw spider::ConnectionException
*/
auto build(T const& t) -> Data;
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

private:
std::unique_ptr<DataImpl> m_impl;
};
Comment on lines +77 to +79
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add destructor declaration for pImpl idiom.

When using the pImpl idiom with std::unique_ptr, you need to declare the destructor in the header and define it in the implementation file where the complete type is available.

Add the following declaration:

~Data();  // Declaration only, define in .cpp file

} // namespace spider

#endif // SPIDER_CLIENT_DATA_HPP
139 changes: 139 additions & 0 deletions src/spider/client/Driver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#ifndef SPIDER_CLIENT_DRIVER_HPP
#define SPIDER_CLIENT_DRIVER_HPP

#include <optional>
#include <string>
#include <vector>

#include <boost/uuid/uuid.hpp>

#include "../worker/FunctionManager.hpp"
#include "Job.hpp"
#include "task.hpp"
#include "TaskGraph.hpp"

/**
* Registers a Task function with Spider
* @param func
*/
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define SPIDER_REGISTER_TASK(func) SPIDER_WORKER_REGISTER_TASK(func)

/**
* Registers a timed Task function with Spider
* @param func
* @param timeout The time after which the task is considered a straggler, triggering Spider to
* replicate the task. TODO: Use the timeout.
*/
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define SPIDER_REGISTER_TASK_TIMEOUT(func, timeout) SPIDER_WORKER_REGISTER_TASK(func)
Comment on lines +26 to +29
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Timeout parameter is unused in SPIDER_REGISTER_TASK_TIMEOUT macro

The SPIDER_REGISTER_TASK_TIMEOUT macro accepts a timeout parameter, but it is not utilized within the macro definition. This could lead to confusion or unexpected behaviour if users expect the timeout functionality to be active. Consider modifying the macro to use the timeout parameter or implementing the timeout feature as noted in the TODO comment.

Would you like assistance in implementing the timeout functionality, or should we open a new GitHub issue to track this task?


namespace spider {

/**
* An interface for a client to interact with Spider and create jobs, access the kv-store, etc.
*/
class Driver {
public:
/**
* @param storage_url
* @throw spider::ConnectionException
*/
explicit Driver(std::string const& storage_url);

/**
* @param storage_url
* @param id A caller-specified ID to associate with this driver. All jobs created by this
* driver will be associated with this ID. This may be useful if, for instance, the caller
* fails and then needs to reconnect and retrieve all previously created jobs. NOTE: It is
* undefined behaviour for two clients to concurrently use the same ID.
* @throw spider::ConnectionException
* @throw spider::DriverIdInUseException
*/
Driver(std::string const& storage_url, boost::uuids::uuid id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should throw an exception if the client ID is already in use, right?


/**
* Inserts the given key-value pair into the key-value store, overwriting any existing value.
*
* @param key
* @param value
* @throw spider::ConnectionException
*/
auto kv_store_insert(std::string const& key, std::string const& value);

/**
* Gets the value corresponding to the given key.
*
* NOTE: Callers cannot get values created by other clients, but they can get values created by
* previous `Driver` instances with the same client ID.
*
* @param key
* @return An optional containing the value if the given key exists, or `std::nullopt`
* otherwise.
* @throw spider::ConnectionException
*/
auto kv_store_get(std::string const& key) -> std::optional<std::string>;

/**
* Binds inputs to a task. Inputs can be:
* - the outputs of a task or task graph, forming dependencies between tasks.
* - any value that satisfies the `TaskIo` concept.
*
* @tparam ReturnType Return type for both the task and the resulting `TaskGraph`.
* @tparam TaskParams
* @tparam Inputs
* @tparam GraphParams
* @param task
* @param inputs Inputs to bind to `task`. If an input is a `Task` or `TaskGraph`, their
* outputs will be bound to the inputs of `task`.
* @return A `TaskGraph` of the inputs bound to `task`.
*/
template <
TaskIo ReturnType,
TaskIo... TaskParams,
RunnableOrTaskIo... Inputs,
TaskIo... GraphParams>
auto bind(TaskFunction<ReturnType, TaskParams...> const& task, Inputs&&... inputs)
-> TaskGraph<ReturnType(GraphParams...)>;

/**
* Starts running a task with the given inputs on Spider.
*
* @tparam ReturnType
* @tparam Params
* @param task
* @param inputs
* @return A job representing the running task.
* @throw spider::ConnectionException
*/
template <TaskIo ReturnType, TaskIo... Params>
auto
start(TaskFunction<ReturnType, Params...> const& task, Params&&... inputs) -> Job<ReturnType>;

/**
* Starts running a task graph with the given inputs on Spider.
*
* @tparam ReturnType
* @tparam Params
* @param graph
* @param inputs
* @return A job representing the running task graph.
* @throw spider::ConnectionException
*/
template <TaskIo ReturnType, TaskIo... Params>
auto
start(TaskGraph<ReturnType(Params...)> const& graph, Params&&... inputs) -> Job<ReturnType>;

/**
* Gets all scheduled and running jobs started by drivers with the current client's ID.
*
* NOTE: This method will not return jobs that have finished.
*
* @return IDs of the jobs.
* @throw spider::ConnectionException
*/
auto get_jobs() -> std::vector<boost::uuids::uuid>;
};
} // namespace spider

#endif // SPIDER_CLIENT_DRIVER_HPP
37 changes: 37 additions & 0 deletions src/spider/client/Exception.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef SPIDER_CLIENT_EXCEPTION_HPP
#define SPIDER_CLIENT_EXCEPTION_HPP

#include <exception>
#include <string>

#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <fmt/format.h>

namespace spider {
class ConnectionException final : public std::exception {
public:
explicit ConnectionException(std::string const& addr)
: m_message(fmt::format("Cannot connect to storage {}.", addr)) {}

[[nodiscard]] auto what() const noexcept -> char const* override { return m_message.c_str(); }

private:
std::string m_message;
};

class DriverIdInUseException final : public std::exception {
public:
explicit DriverIdInUseException(boost::uuids::uuid id)
: m_message(
fmt::format("Driver ID {} is currently in use.", boost::uuids::to_string(id))
) {}

[[nodiscard]] auto what() const noexcept -> char const* override { return m_message.c_str(); }

private:
std::string m_message;
};
} // namespace spider

#endif // SPIDER_CLIENT_EXCEPTION_HPP
72 changes: 72 additions & 0 deletions src/spider/client/Job.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#ifndef SPIDER_CLIENT_JOB_HPP
#define SPIDER_CLIENT_JOB_HPP

#include <cstdint>
#include <string>
#include <utility>

#include "task.hpp"

namespace spider {
// TODO: Use std::expected or Boost's outcome so that the user can get the result of the job in one
// call rather than the current error-prone approach which requires that the user check the job's
// status and then call the relevant method.

enum class JobStatus : uint8_t {
Running,
Succeeded,
Failed,
Cancelled,
};

/**
* A running task graph.
*
* @tparam ReturnType
*/
template <TaskIo ReturnType>
class Job {
public:
/**
* Waits for the job to complete.
*
* @throw spider::ConnectionException
*/
auto wait_complete();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Template implementation file is missing

The methods in the Job template class are declared but have no implementation. No source files (.cpp), template implementation files (.ipp/.tpp), or inline implementations were found. This could lead to linker errors.

  • Add a template implementation file (e.g., Job.ipp) with the method implementations
  • Or implement the methods inline in the header file
  • Or provide a source file with explicit template instantiations
🔗 Analysis chain

Add inline keyword for header-only methods

The method declarations don't have implementations. If these are meant to be implemented in a source file, ensure the implementation file exists. If these are meant to be header-only, mark them as inline.

Also applies to: 41-41, 46-46, 54-54, 63-63

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if there's a corresponding source file
fd "Job\.(cpp|cc|cxx)$" src/spider/client/

# Check if these methods are implemented elsewhere
rg "Job<.*>::(wait_complete|cancel|get_status|get_result|get_error)"

Length of output: 115


Script:

#!/bin/bash
# Let's check the Job.hpp file content to see if methods are implemented inline
cat src/spider/client/Job.hpp

# Also check for any potential template implementation files
fd "Job\..*" src/spider/client/

Length of output: 1664


Script:

#!/bin/bash
# Let's check if there's a template implementation file with .ipp or .tpp extension
fd "Job\.(ipp|tpp)$" src/spider/

# Let's also check if implementations are in a separate template implementation file
rg -l "template.*Job<.*>::(wait_complete|cancel|get_status|get_result|get_error)"

# Check JobImpl implementation as it might contain the actual implementations
fd "JobImpl\.(hpp|cpp|cc|h)$" src/spider/

Length of output: 162


/**
* Cancels the job and waits for the job's tasks to be cancelled.
*
* @throw spider::ConnectionException
*/
auto cancel();

/**
* @return Status of the job.
* @throw spider::ConnectionException
*/
auto get_status() -> JobStatus;

/**
* NOTE: It is undefined behavior to call this method for a job that is not in the `Succeeded`
* state.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the job state names in the documentation

There are inconsistencies in the documentation comments regarding job state names:

  • In line 54, 'Succeed' should be 'Succeeded' to match the enum JobStatus::Succeeded.
  • In line 63, 'Fail' should be 'Failed' to match the enum JobStatus::Failed.

Apply the following changes to correct the documentation:

- * NOTE: It is undefined behaviour to call this method for a job that is not in the `Succeed` state.
+ * NOTE: It is undefined behaviour to call this method for a job that is not in the `Succeeded` state.
- * NOTE: It is undefined behaviour to call this method for a job that is not in the `Fail` state.
+ * NOTE: It is undefined behaviour to call this method for a job that is not in the `Failed` state.

Also applies to: 63-63

*
* @return Result of the job.
* @throw spider::ConnectionException
*/
auto get_result() -> ReturnType;

/**
* NOTE: It is undefined behavior to call this method for a job that is not in the `Failed`
* state.
*
* @return A pair:
* - the name of the task function that failed.
* - the error message sent from the task through `TaskContext::abort` or from Spider.
* @throw spider::ConnectionException
*/
auto get_error() -> std::pair<std::string, std::string>;
};
} // namespace spider

#endif // SPIDER_CLIENT_JOB_HPP
Loading