aboutsummaryrefslogtreecommitdiffstats
path: root/yt/yt/core/bus/tcp/config.h
blob: e2a1ec47f6ea9c753ce5b269acdaf0f2bf70d443 (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
#pragma once

#include "public.h"

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

#include <yt/yt/core/ytree/yson_struct.h>

namespace NYT::NBus {

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

class TMultiplexingBandConfig
    : public NYTree::TYsonStruct
{
public:
    int TosLevel;
    THashMap<TString, int> NetworkToTosLevel;

    REGISTER_YSON_STRUCT(TMultiplexingBandConfig);

    static void Register(TRegistrar registrar);
};

DEFINE_REFCOUNTED_TYPE(TMultiplexingBandConfig)

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

class TTcpDispatcherConfig
    : public NYTree::TYsonStruct
{
public:
    int ThreadPoolSize;

    //! Used for profiling export and alerts.
    std::optional<i64> NetworkBandwidth;

    THashMap<TString, std::vector<NNet::TIP6Network>> Networks;

    TEnumIndexedVector<EMultiplexingBand, TMultiplexingBandConfigPtr> MultiplexingBands;

    TTcpDispatcherConfigPtr ApplyDynamic(const TTcpDispatcherDynamicConfigPtr& dynamicConfig) const;

    REGISTER_YSON_STRUCT(TTcpDispatcherConfig);

    static void Register(TRegistrar registrar);
};

DEFINE_REFCOUNTED_TYPE(TTcpDispatcherConfig)

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

class TTcpDispatcherDynamicConfig
    : public NYTree::TYsonStruct
{
public:
    std::optional<int> ThreadPoolSize;

    std::optional<i64> NetworkBandwidth;

    std::optional<THashMap<TString, std::vector<NNet::TIP6Network>>> Networks;

    std::optional<TEnumIndexedVector<EMultiplexingBand, TMultiplexingBandConfigPtr>> MultiplexingBands;

    REGISTER_YSON_STRUCT(TTcpDispatcherDynamicConfig);

    static void Register(TRegistrar registrar);
};

DEFINE_REFCOUNTED_TYPE(TTcpDispatcherDynamicConfig)

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

class TBusConfig
    : public NNet::TDialerConfig
{
public:
    bool EnableQuickAck;

    int BindRetryCount;
    TDuration BindRetryBackoff;

    TDuration ReadStallTimeout;
    TDuration WriteStallTimeout;

    bool VerifyChecksums;
    bool GenerateChecksums;

    REGISTER_YSON_STRUCT(TBusConfig);

    static void Register(TRegistrar registrar);
};

DEFINE_REFCOUNTED_TYPE(TBusConfig)

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

class TBusServerConfig
    : public TBusConfig
{
public:
    std::optional<int> Port;
    std::optional<TString> UnixDomainSocketPath;
    int MaxBacklogSize;
    int MaxSimultaneousConnections;

    static TBusServerConfigPtr CreateTcp(int port);
    static TBusServerConfigPtr CreateUds(const TString& socketPath);

    REGISTER_YSON_STRUCT(TBusServerConfig);

    static void Register(TRegistrar registrar);
};

DEFINE_REFCOUNTED_TYPE(TBusServerConfig)

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

class TBusClientConfig
    : public TBusConfig
{
public:
    std::optional<TString> Address;
    std::optional<TString> UnixDomainSocketPath;

    static TBusClientConfigPtr CreateTcp(const TString& address);
    static TBusClientConfigPtr CreateUds(const TString& socketPath);

    REGISTER_YSON_STRUCT(TBusClientConfig);

    static void Register(TRegistrar registrar);
};

DEFINE_REFCOUNTED_TYPE(TBusClientConfig)

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

} // namespace NYT::NBus