Merge cdc_stream into asset_stream_manager (#26)

Adds start and stop commands to asset_stream_manager.
asset_stream_manager will be renamed to cdc_stream next.
This commit is contained in:
Lutz Justen
2022-12-01 12:40:00 +01:00
committed by GitHub
parent 876e59409f
commit f0539226a2
23 changed files with 507 additions and 281 deletions

View File

@@ -1,62 +0,0 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "cdc_stream/local_assets_stream_manager_client.h"
#include "absl/status/status.h"
#include "common/grpc_status.h"
namespace cdc_ft {
using StartSessionRequest = localassetsstreammanager::StartSessionRequest;
using StartSessionResponse = localassetsstreammanager::StartSessionResponse;
using StopSessionRequest = localassetsstreammanager::StopSessionRequest;
using StopSessionResponse = localassetsstreammanager::StopSessionResponse;
LocalAssetsStreamManagerClient::LocalAssetsStreamManagerClient(
std::shared_ptr<grpc::Channel> channel) {
stub_ = LocalAssetsStreamManager::NewStub(std::move(channel));
}
LocalAssetsStreamManagerClient::~LocalAssetsStreamManagerClient() = default;
absl::Status LocalAssetsStreamManagerClient::StartSession(
const std::string& src_dir, const std::string& user_host, uint16_t ssh_port,
const std::string& mount_dir, const std::string& ssh_command,
const std::string& scp_command) {
StartSessionRequest request;
request.set_workstation_directory(src_dir);
request.set_user_host(user_host);
request.set_port(ssh_port);
request.set_mount_dir(mount_dir);
request.set_ssh_command(ssh_command);
request.set_scp_command(scp_command);
grpc::ClientContext context;
StartSessionResponse response;
return ToAbslStatus(stub_->StartSession(&context, request, &response));
}
absl::Status LocalAssetsStreamManagerClient::StopSession(
const std::string& user_host, const std::string& mount_dir) {
StopSessionRequest request;
request.set_user_host(user_host);
request.set_mount_dir(mount_dir);
grpc::ClientContext context;
StopSessionResponse response;
return ToAbslStatus(stub_->StopSession(&context, request, &response));
}
} // namespace cdc_ft