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

Users/drbasic/23 3/vhost #1602

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions cloud/blockstore/config/server.proto
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ message TServerConfig

// Causes E_NOT_IMPLEMENTED errors in endpoint storages to be logged.
optional bool EndpointStorageNotImplementedErrorIsFatal = 116;

// auth token for node registration via ydb discovery api.
optional string NodeRegistrationToken = 117;

// How many seconds will the external vhost server continue to work after
// the parent process die.
optional uint32 VhostServerTimeoutAfterParentExit = 118;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions cloud/blockstore/libs/daemon/common/bootstrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ void TBootstrapBase::Init()
? TString {}
: FQDNHostName(),
Configs->ServerConfig->GetSocketAccessMode(),
Configs->ServerConfig->GetVhostServerTimeoutAfterParentExit(),
std::move(vhostEndpointListener));

STORAGE_INFO("VHOST External Vhost EndpointListener initialized");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ add_library(blockstore-libs-endpoints_vhost)
target_link_libraries(blockstore-libs-endpoints_vhost PUBLIC
contrib-libs-linux-headers
contrib-libs-cxxsupp
cpp-getopt-small
yutil
blockstore-libs-client
blockstore-libs-common
Expand Down
47 changes: 47 additions & 0 deletions cloud/blockstore/libs/endpoints_vhost/cont_io_with_timeout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include <library/cpp/coroutine/engine/sockpool.h>

#include <util/stream/input.h>
#include <util/stream/output.h>

namespace NCloud::NBlockStore::NServer {

///////////////////////////////////////////////////////////////////////////////

// Similar to TContIO, but DoWrite() and DoRead() operations are executed with a
// timeout.
class TContIOWithTimeout
: public IInputStream
, public IOutputStream
{
SOCKET Fd_;
TCont* Cont_;
TDuration Timeout;

public:
TContIOWithTimeout(SOCKET fd, TCont* cont, TDuration timeout)
: Fd_(fd)
, Cont_(cont)
, Timeout(timeout)
{}

void DoWrite(const void* buf, size_t len) override
{
NCoro::WriteD(Cont_, Fd_, buf, len, TInstant::Now() + Timeout)
.Checked();
}

size_t DoRead(void* buf, size_t len) override
{
return NCoro::ReadD(Cont_, Fd_, buf, len, TInstant::Now() + Timeout)
.Checked();
}

SOCKET Fd() const noexcept
{
return Fd_;
}
};

} // namespace NCloud::NBlockStore::NServer
Loading
Loading