aboutsummaryrefslogtreecommitdiffstats
path: root/yt/yt/core/bus/tcp/config.cpp
blob: ed0074651f7476742f9e77605ed707982e43d026 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include "config.h"

#include <yt/yt/core/net/address.h>

namespace NYT::NBus {

using namespace NYTree;

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

void TMultiplexingBandConfig::Register(TRegistrar registrar)
{
    registrar.Parameter("tos_level", &TThis::TosLevel)
        .Default(NYT::NBus::DefaultTosLevel);

    registrar.Parameter("network_to_tos_level", &TThis::NetworkToTosLevel)
        .Default();
}

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

void TTcpDispatcherConfig::Register(TRegistrar registrar)
{
    registrar.Parameter("thread_pool_size", &TThis::ThreadPoolSize)
        .Default(8);

    registrar.Parameter("network_bandwidth", &TThis::NetworkBandwidth)
        .Default();

    registrar.Parameter("networks", &TThis::Networks)
        .Default();

    registrar.Parameter("multiplexing_bands", &TThis::MultiplexingBands)
        .Default();
}

TTcpDispatcherConfigPtr TTcpDispatcherConfig::ApplyDynamic(
    const TTcpDispatcherDynamicConfigPtr& dynamicConfig) const
{
    auto mergedConfig = CloneYsonStruct(MakeStrong(this));
    UpdateYsonStructField(mergedConfig->ThreadPoolSize, dynamicConfig->ThreadPoolSize);
    UpdateYsonStructField(mergedConfig->Networks, dynamicConfig->Networks);
    UpdateYsonStructField(mergedConfig->MultiplexingBands, dynamicConfig->MultiplexingBands);
    mergedConfig->Postprocess();
    return mergedConfig;
}

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

void TTcpDispatcherDynamicConfig::Register(TRegistrar registrar)
{
    registrar.Parameter("thread_pool_size", &TThis::ThreadPoolSize)
        .Optional()
        .GreaterThan(0);

    registrar.Parameter("network_bandwidth", &TThis::NetworkBandwidth)
        .Default();

    registrar.Parameter("networks", &TThis::Networks)
        .Default();

    registrar.Parameter("multiplexing_bands", &TThis::MultiplexingBands)
        .Optional();
}

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

void TBusServerConfig::Register(TRegistrar registrar)
{
    registrar.Parameter("port", &TThis::Port)
        .Default();
    registrar.Parameter("unix_domain_socket_path", &TThis::UnixDomainSocketPath)
        .Default();
    registrar.Parameter("max_backlog_size", &TThis::MaxBacklogSize)
        .Default(8192);
    registrar.Parameter("max_simultaneous_connections", &TThis::MaxSimultaneousConnections)
        .Default(50000);
}

TBusServerConfigPtr TBusServerConfig::CreateTcp(int port)
{
    auto config = New<TBusServerConfig>();
    config->Port = port;
    return config;
}

TBusServerConfigPtr TBusServerConfig::CreateUds(const TString& socketPath)
{
    auto config = New<TBusServerConfig>();
    config->UnixDomainSocketPath = socketPath;
    return config;
}

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

void TBusConfig::Register(TRegistrar registrar)
{
    registrar.Parameter("enable_quick_ack", &TThis::EnableQuickAck)
        .Default(true);
    registrar.Parameter("bind_retry_count", &TThis::BindRetryCount)
        .Default(5);
    registrar.Parameter("bind_retry_backoff", &TThis::BindRetryBackoff)
        .Default(TDuration::Seconds(3));
    registrar.Parameter("read_stall_timeout", &TThis::ReadStallTimeout)
        .Default(TDuration::Minutes(1));
    registrar.Parameter("write_stall_timeout", &TThis::WriteStallTimeout)
        .Default(TDuration::Minutes(1));
    registrar.Parameter("verify_checksums", &TThis::VerifyChecksums)
        .Default(true);
    registrar.Parameter("generate_checksums", &TThis::GenerateChecksums)
        .Default(true);
    registrar.Parameter("encryption_mode", &TThis::EncryptionMode)
        .Default(EEncryptionMode::Optional);
    registrar.Parameter("verification_mode", &TThis::VerificationMode)
        .Default(EVerificationMode::None);
    registrar.Parameter("ca_file", &TThis::CAFile)
        .Default();
    registrar.Parameter("cert_chain_file", &TThis::CertificateChainFile)
        .Default();
    registrar.Parameter("private_key_file", &TThis::PrivateKeyFile)
        .Default();
    registrar.Parameter("cipher_list", &TThis::CipherList)
        .Default();
    registrar.Parameter("use_key_pair_from_ssl_context", &TThis::UseKeyPairFromSslContext)
        .Default(false);
}

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

void TBusClientConfig::Register(TRegistrar registrar)
{
    registrar.Parameter("address", &TThis::Address)
        .Default();
    registrar.Parameter("unix_domain_socket_path", &TThis::UnixDomainSocketPath)
        .Default();

    registrar.Postprocessor([] (TThis* config) {
        if (!config->Address && !config->UnixDomainSocketPath) {
            THROW_ERROR_EXCEPTION("\"address\" and \"unix_domain_socket_path\" cannot be both missing");
        }
    });
}

TBusClientConfigPtr TBusClientConfig::CreateTcp(const TString& address)
{
    auto config = New<TBusClientConfig>();
    config->Address = address;
    return config;
}

TBusClientConfigPtr TBusClientConfig::CreateUds(const TString& socketPath)
{
    auto config = New<TBusClientConfig>();
    config->UnixDomainSocketPath = socketPath;
    return config;
}

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

} // namespace NYT::NBus