Contribute#
Overall guidance on contributing to a PyAnsys library appears in the Contributing topic in the PyAnsys developer’s guide. Ensure that you are thoroughly familiar with this guide before attempting to contribute to the FileTransfer Tool Server.
Setup#
For information on how to build the FileTransfer Tool Server from source, see Getting started.
To build the documentation, use this command:
poetry run -C doc html
To run tests, use this command:
cd build; ctest; cd ..
To run
pre-commit
style checks, run this command:poetry run pre-commit run --all-files
Internal API#
Documentation follows for the internal classes and functions of the FileTransfer Tool Server. This documentation is intended for developers who want to understand the inner workings of the server and possibly extend it.
-
namespace file_transfer#
Typedefs
-
using pb_progress_t = decltype(::ansys::api::tools::filetransfer::v1::ProgressResponse().state())#
-
using pb_filesize_t = decltype(::ansys::api::tools::filetransfer::v1::FileInfo().size())#
Enums
-
class FileTransferServiceImpl : public ansys::api::tools::filetransfer::v1::FileTransferService::Service#
This class implements the file transfer service.
Public Functions
-
virtual auto DownloadFile(::grpc::ServerContext *context, ::grpc::ServerReaderWriter<::ansys::api::tools::filetransfer::v1::DownloadFileResponse, ::ansys::api::tools::filetransfer::v1::DownloadFileRequest> *stream) -> ::grpc::Status override#
Implements the “DownloadFile” operation.
- Parameters:
context – Server context to use.
stream – Stream of requests and responses to process.
- Returns:
Result of the operation.
-
virtual auto UploadFile(::grpc::ServerContext *context, ::grpc::ServerReaderWriter<::ansys::api::tools::filetransfer::v1::UploadFileResponse, ::ansys::api::tools::filetransfer::v1::UploadFileRequest> *stream) -> ::grpc::Status override#
Implements the “UploadFile” operation.
- Parameters:
context – Server context to use.
stream – Stream of requests and responses to process.
- Returns:
Result of the operation.
-
virtual auto DownloadFile(::grpc::ServerContext *context, ::grpc::ServerReaderWriter<::ansys::api::tools::filetransfer::v1::DownloadFileResponse, ::ansys::api::tools::filetransfer::v1::DownloadFileRequest> *stream) -> ::grpc::Status override#
-
namespace detail#
Functions
-
auto get_sha1_hex_digest(const boost::filesystem::path &path_, const std::streamsize chunk_size_ = 1024) -> std::string#
Get the SHA1 hex digest of a file.
Note
This function is not thread-safe.
- Parameters:
path_ – Path to the file.
chunk_size_ – Size of the chunks to read from the file.
- Returns:
SHA1 hex digest of the file.
-
auto get_sha1_hex_digest(const boost::filesystem::path &path_, const std::streamsize chunk_size_ = 1024) -> std::string#
-
namespace download_impl#
Typedefs
-
using stream_t = ::grpc::ServerReaderWriter<api::DownloadFileResponse, api::DownloadFileRequest>#
Functions
-
auto get_request_checked(google::protobuf::Arena &arena_, stream_t *stream_, const api::DownloadFileRequest::SubStepCase &expected_step_) -> api::DownloadFileRequest*#
-
auto initialize(google::protobuf::Arena &arena_, stream_t *stream_) -> std::tuple<const boost::filesystem::path, const std::size_t, const std::streamsize>#
-
using stream_t = ::grpc::ServerReaderWriter<api::DownloadFileResponse, api::DownloadFileRequest>#
-
namespace exceptions#
Functions
-
auto convert_exceptions_to_status_codes(const std::function<void()>&) -> ::grpc::Status#
Convert exceptions to gRPC status codes.
- Parameters:
fun – Function to execute.
- Returns:
gRPC status code.
-
class not_found : public std::runtime_error#
Exception type raised when an object is not found.
-
class invalid_argument : public std::runtime_error#
Exception type raised when invalid parameters are provided.
-
class failed_precondition : public std::runtime_error#
Exception type raised when some precondition is not met. For example, a file is expected to exist, but it does not.
-
class data_loss : public std::runtime_error#
Exception type raised when the transmitted data is lost or corrupted.
-
class internal : public std::runtime_error#
Exception type raised when an internal error occurs.
-
namespace detail#
Functions
-
template<typename ExceptionT>
auto get_exception_message(const ExceptionT &exc) -> std::string#
-
template<typename ExceptionT>
-
auto convert_exceptions_to_status_codes(const std::function<void()>&) -> ::grpc::Status#
-
namespace upload_impl#
Typedefs
-
using stream_t = ::grpc::ServerReaderWriter<api::UploadFileResponse, api::UploadFileRequest>#
Functions
-
auto get_request_checked(api::UploadFileRequest *request_, stream_t *stream_, const api::UploadFileRequest::SubStepCase &expected_step_) -> void#
-
auto get_request_checked(google::protobuf::Arena &arena_, stream_t *stream_, const api::UploadFileRequest::SubStepCase &expected_step_) -> api::UploadFileRequest*#
-
auto initialize(google::protobuf::Arena &arena_, stream_t *stream_) -> std::tuple<const boost::filesystem::path, const std::size_t, const std::string>#
-
using stream_t = ::grpc::ServerReaderWriter<api::UploadFileResponse, api::UploadFileRequest>#
-
using pb_progress_t = decltype(::ansys::api::tools::filetransfer::v1::ProgressResponse().state())#