|
@@ -1135,6 +1135,46 @@ public:
|
|
|
return info;
|
|
return info;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // ===== Read-Only Control =====
|
|
|
|
|
+
|
|
|
|
|
+ bool setReadOnly(bool readOnly) {
|
|
|
|
|
+ smartbotic::databasepb::SetReadOnlyRequest request;
|
|
|
|
|
+ request.set_read_only(readOnly);
|
|
|
|
|
+ smartbotic::databasepb::SetReadOnlyResponse response;
|
|
|
|
|
+ grpc::ClientContext context;
|
|
|
|
|
+ setDeadline(context);
|
|
|
|
|
+
|
|
|
|
|
+ auto status = stub_->SetReadOnly(&context, request, &response);
|
|
|
|
|
+ if (!status.ok()) {
|
|
|
|
|
+ spdlog::error("Client::setReadOnly failed: {}", status.error_message());
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return response.success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Client::ReadOnlyStatus getReadOnlyStatus() {
|
|
|
|
|
+ smartbotic::databasepb::GetReadOnlyStatusRequest request;
|
|
|
|
|
+ smartbotic::databasepb::GetReadOnlyStatusResponse response;
|
|
|
|
|
+ grpc::ClientContext context;
|
|
|
|
|
+ setDeadline(context);
|
|
|
|
|
+
|
|
|
|
|
+ Client::ReadOnlyStatus out;
|
|
|
|
|
+ auto status = stub_->GetReadOnlyStatus(&context, request, &response);
|
|
|
|
|
+ if (!status.ok()) {
|
|
|
|
|
+ spdlog::error("Client::getReadOnlyStatus failed: {}", status.error_message());
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+ out.readOnly = response.read_only();
|
|
|
|
|
+ out.reason = response.reason();
|
|
|
|
|
+ out.recoveryOutcome = response.recovery_outcome();
|
|
|
|
|
+ out.expectedSnapshot = response.expected_snapshot();
|
|
|
|
|
+ out.snapshotUsed = response.snapshot_used();
|
|
|
|
|
+ out.failureReason = response.failure_reason();
|
|
|
|
|
+ out.walEntriesReplayed = response.wal_entries_replayed();
|
|
|
|
|
+ out.snapshotsAttempted = response.snapshots_attempted();
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// ===== File Operations =====
|
|
// ===== File Operations =====
|
|
|
|
|
|
|
|
Client::FileUploadResult uploadFile(const std::vector<uint8_t>& data, const Client::FileUploadMeta& meta) {
|
|
Client::FileUploadResult uploadFile(const std::vector<uint8_t>& data, const Client::FileUploadMeta& meta) {
|
|
@@ -1508,6 +1548,14 @@ std::optional<Client::StatsInfo> Client::getStats() {
|
|
|
return impl_->getStats();
|
|
return impl_->getStats();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+bool Client::setReadOnly(bool readOnly) {
|
|
|
|
|
+ return impl_->setReadOnly(readOnly);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+Client::ReadOnlyStatus Client::getReadOnlyStatus() {
|
|
|
|
|
+ return impl_->getReadOnlyStatus();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
Client::FileUploadResult Client::uploadFile(const std::vector<uint8_t>& data, const FileUploadMeta& meta) {
|
|
Client::FileUploadResult Client::uploadFile(const std::vector<uint8_t>& data, const FileUploadMeta& meta) {
|
|
|
return impl_->uploadFile(data, meta);
|
|
return impl_->uploadFile(data, meta);
|
|
|
}
|
|
}
|