Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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 examples/topic_reader/eventloop/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main(int argc, const char* argv[]) {
.SetEndpoint(opts.Endpoint)
.SetDatabase(opts.Database)
.SetAuthToken(std::getenv("YDB_TOKEN") ? std::getenv("YDB_TOKEN") : "")
.SetLog(CreateLogBackend("cerr"));
.SetLog(std::unique_ptr<TLogBackend>(CreateLogBackend("cerr").Get()));

if (opts.UseSecureConnection) {
driverConfig.UseSecureConnection();
Expand Down
2 changes: 1 addition & 1 deletion examples/topic_reader/simple/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ int main(int argc, const char* argv[]) {
.SetEndpoint(opts.Endpoint)
.SetDatabase(opts.Database)
.SetAuthToken(std::getenv("YDB_TOKEN") ? std::getenv("YDB_TOKEN") : "")
.SetLog(CreateLogBackend("cerr"));
.SetLog(std::unique_ptr<TLogBackend>(CreateLogBackend("cerr").Get()));

if (opts.UseSecureConnection) {
driverConfig.UseSecureConnection();
Expand Down
2 changes: 1 addition & 1 deletion examples/topic_reader/transaction/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TApplication::TApplication(const TOptions& options)
.SetEndpoint(options.Endpoint)
.SetDatabase(options.Database)
.SetAuthToken(std::getenv("YDB_TOKEN") ? std::getenv("YDB_TOKEN") : "")
.SetLog(CreateLogBackend("cerr", Min(options.LogPriority, TLOG_RESOURCES)));
.SetLog(std::unique_ptr<TLogBackend>(CreateLogBackend("cerr", Min(options.LogPriority, TLOG_RESOURCES)).Get()));
if (options.UseSecureConnection) {
config.UseSecureConnection();
}
Expand Down
4 changes: 2 additions & 2 deletions include/ydb-cpp-sdk/client/driver/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class TDriverConfig {
TDriverConfig& SetMaxMessageSize(ui64 maxMessageSize);

//! Log backend.
TDriverConfig& SetLog(THolder<TLogBackend> log);
TDriverConfig& SetLog(std::unique_ptr<TLogBackend>&& log);
private:
class TImpl;
std::shared_ptr<TImpl> Impl_;
Expand Down Expand Up @@ -147,4 +147,4 @@ class TDriver {
std::shared_ptr<TGRpcConnectionsImpl> Impl_;
};

} // namespace NYdb
} // namespace NYdb
8 changes: 4 additions & 4 deletions include/ydb-cpp-sdk/client/federated_topic/federated_topic.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class TDeferredCommit {

private:
class TImpl;
THolder<TImpl> Impl;
std::unique_ptr<TImpl> Impl;
};

//! Event debug string.
Expand Down Expand Up @@ -507,7 +507,7 @@ class TFederatedTopicClient {
// executors from settings are passed to subclients
TFederatedTopicClient(const TDriver& driver, const TFederatedTopicClientSettings& settings = {});

void ProvideCodec(NTopic::ECodec codecId, THolder<NTopic::ICodec>&& codecImpl);
void ProvideCodec(NTopic::ECodec codecId, std::unique_ptr<NTopic::ICodec>&& codecImpl);

//! Create read session.
std::shared_ptr<IFederatedReadSession> CreateReadSession(const TFederatedReadSessionSettings& settings);
Expand All @@ -517,7 +517,7 @@ class TFederatedTopicClient {
std::shared_ptr<NTopic::IWriteSession> CreateWriteSession(const TFederatedWriteSessionSettings& settings);

protected:
void OverrideCodec(NTopic::ECodec codecId, THolder<NTopic::ICodec>&& codecImpl);
void OverrideCodec(NTopic::ECodec codecId, std::unique_ptr<NTopic::ICodec>&& codecImpl);

private:
std::shared_ptr<TImpl> Impl_;
Expand Down Expand Up @@ -550,4 +550,4 @@ void TPrintable<NFederatedTopic::TReadSessionEvent::TFederated<NFederatedTopic::
template<>
void TPrintable<NFederatedTopic::TReadSessionEvent::TFederated<NFederatedTopic::TReadSessionEvent::TPartitionSessionClosedEvent>>::DebugString(TStringBuilder& res, bool) const;

}
}
12 changes: 6 additions & 6 deletions include/ydb-cpp-sdk/client/iam/common/iam.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TGrpcIamCredentialsProvider : public ICredentialsProvider {
class TImpl : public std::enable_shared_from_this<TGrpcIamCredentialsProvider<TRequest, TResponse, TService>::TImpl> {
public:
TImpl(const TIamEndpoint& iamEndpoint, const TRequestFiller& requestFiller)
: Client(MakeHolder<NYdbGrpc::TGRpcClientLow>())
: Client(std::make_unique<NYdbGrpc::TGRpcClientLow>())
, Connection_(nullptr)
, Ticket_("")
, NextTicketUpdate_(TInstant::Zero())
Expand All @@ -92,7 +92,7 @@ class TGrpcIamCredentialsProvider : public ICredentialsProvider {
NYdbGrpc::TGRpcClientConfig grpcConf;
grpcConf.Locator = IamEndpoint_.Endpoint;
grpcConf.EnableSsl = IamEndpoint_.EnableSsl;
Connection_ = THolder<NYdbGrpc::TServiceConnection<TService>>(Client->CreateGRpcServiceConnection<TService>(grpcConf).release());
Connection_ = std::unique_ptr<NYdbGrpc::TServiceConnection<TService>>(Client->CreateGRpcServiceConnection<TService>(grpcConf).release());
}

void UpdateTicket(bool sync = false) {
Expand Down Expand Up @@ -155,7 +155,7 @@ class TGrpcIamCredentialsProvider : public ICredentialsProvider {
NeedStop_ = true;
}

Client.Reset(); // Will trigger destroy
Client.reset(); // Will trigger destroy
}

private:
Expand Down Expand Up @@ -197,8 +197,8 @@ class TGrpcIamCredentialsProvider : public ICredentialsProvider {

private:

THolder<NYdbGrpc::TGRpcClientLow> Client;
THolder<NYdbGrpc::TServiceConnection<TService>> Connection_;
std::unique_ptr<NYdbGrpc::TGRpcClientLow> Client;
std::unique_ptr<NYdbGrpc::TServiceConnection<TService>> Connection_;
std::string Ticket_;
TInstant NextTicketUpdate_;
const TIamEndpoint IamEndpoint_;
Expand Down Expand Up @@ -279,4 +279,4 @@ class TIamOAuthCredentialsProviderFactory : public ICredentialsProviderFactory {
TIamOAuth Params_;
};

} // namespace NYdb
} // namespace NYdb
6 changes: 3 additions & 3 deletions include/ydb-cpp-sdk/client/topic/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TTopicClient {

TTopicClient(const TDriver& driver, const TTopicClientSettings& settings = TTopicClientSettings());

void ProvideCodec(ECodec codecId, THolder<ICodec>&& codecImpl);
void ProvideCodec(ECodec codecId, std::unique_ptr<ICodec>&& codecImpl);

// Create a new topic.
TAsyncStatus CreateTopic(const std::string& path, const TCreateTopicSettings& settings = {});
Expand Down Expand Up @@ -55,10 +55,10 @@ class TTopicClient {
const TCommitOffsetSettings& settings = {});

protected:
void OverrideCodec(ECodec codecId, THolder<ICodec>&& codecImpl);
void OverrideCodec(ECodec codecId, std::unique_ptr<ICodec>&& codecImpl);

private:
std::shared_ptr<TImpl> Impl_;
};

} // namespace NYdb::NTopic
} // namespace NYdb::NTopic
21 changes: 11 additions & 10 deletions include/ydb-cpp-sdk/client/topic/codecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <ydb-cpp-sdk/util/system/spinlock.h>

#include <unordered_map>
#include <memory>

namespace NYdb::NTopic {

Expand All @@ -36,7 +37,7 @@ class ICodec {
public:
virtual ~ICodec() = default;
virtual std::string Decompress(const std::string& data) const = 0;
virtual THolder<IOutputStream> CreateCoder(TBuffer& result, int quality) const = 0;
virtual std::unique_ptr<IOutputStream> CreateCoder(TBuffer& result, int quality) const = 0;
};

class TGzipCodec final : public ICodec {
Expand All @@ -58,8 +59,8 @@ class TGzipCodec final : public ICodec {
return result;
}

THolder<IOutputStream> CreateCoder(TBuffer& result, int quality) const override {
return MakeHolder<TZLibToStringCompressor>(result, ZLib::GZip, quality >= 0 ? quality : 6);
std::unique_ptr<IOutputStream> CreateCoder(TBuffer& result, int quality) const override {
return std::make_unique<TZLibToStringCompressor>(result, ZLib::GZip, quality >= 0 ? quality : 6);
}
};

Expand All @@ -82,8 +83,8 @@ class TZstdCodec final : public ICodec {
return result;
}

THolder<IOutputStream> CreateCoder(TBuffer& result, int quality) const override {
return MakeHolder<TZstdToStringCompressor>(result, quality);
std::unique_ptr<IOutputStream> CreateCoder(TBuffer& result, int quality) const override {
return std::make_unique<TZstdToStringCompressor>(result, quality);
}
};

Expand All @@ -92,7 +93,7 @@ class TUnsupportedCodec final : public ICodec {
throw yexception() << "use of unsupported codec";
}

THolder<IOutputStream> CreateCoder(TBuffer&, int) const override {
std::unique_ptr<IOutputStream> CreateCoder(TBuffer&, int) const override {
throw yexception() << "use of unsupported codec";
}
};
Expand All @@ -104,7 +105,7 @@ class TCodecMap {
return instance;
}

void Set(ui32 codecId, THolder<ICodec>&& codecImpl) {
void Set(ui32 codecId, std::unique_ptr<ICodec>&& codecImpl) {
with_lock(Lock) {
Codecs[codecId] = std::move(codecImpl);
}
Expand All @@ -115,7 +116,7 @@ class TCodecMap {
if (!Codecs.contains(codecId)) {
throw yexception() << "codec with id " << ui32(codecId) << " not provided";
}
return Codecs.at(codecId).Get();
return Codecs.at(codecId).get();
}
}

Expand All @@ -129,8 +130,8 @@ class TCodecMap {
TCodecMap() = default;

private:
std::unordered_map<ui32, THolder<ICodec>> Codecs;
std::unordered_map<ui32, std::unique_ptr<ICodec>> Codecs;
TAdaptiveLock Lock;
};

} // namespace NYdb::NTopic
} // namespace NYdb::NTopic
4 changes: 2 additions & 2 deletions include/ydb-cpp-sdk/client/topic/read_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class TDeferredCommit {

private:
class TImpl;
THolder<TImpl> Impl;
std::unique_ptr<TImpl> Impl;
};

//! Events debug strings.
Expand All @@ -430,4 +430,4 @@ void TPrintable<TSessionClosedEvent>::DebugString(TStringBuilder& ret, bool prin

std::string DebugString(const TReadSessionEvent::TEvent& event);

}
}
Loading
Loading