blob: 93bf292fb0d724ef9b7d4c8446aca58ce740e41f (
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
|
#pragma once
#include "private.h"
namespace NYT::NBus {
////////////////////////////////////////////////////////////////////////////////
DEFINE_ENUM_WITH_UNDERLYING_TYPE(EPacketType, i16,
((Message)(0))
((Ack) (1))
((SslAck) (2))
);
DEFINE_BIT_ENUM_WITH_UNDERLYING_TYPE(EPacketFlags, ui16,
((None) (0x0000))
((RequestAcknowledgement) (0x0001))
);
////////////////////////////////////////////////////////////////////////////////
struct IPacketDecoder
{
virtual ~IPacketDecoder() = default;
virtual void Restart() = 0;
virtual bool IsInProgress() const = 0;
virtual bool IsFinished() const = 0;
virtual TMutableRef GetFragment() = 0;
virtual bool Advance(size_t size) = 0;
virtual EPacketType GetPacketType() const = 0;
virtual EPacketFlags GetPacketFlags() const = 0;
virtual TPacketId GetPacketId() const = 0;
virtual size_t GetPacketSize() const = 0;
virtual TSharedRefArray GrabMessage() const = 0;
};
struct IPacketEncoder
{
virtual ~IPacketEncoder() = default;
virtual size_t GetPacketSize(
EPacketType type,
const TSharedRefArray& message,
size_t payloadSize) = 0;
virtual bool Start(
EPacketType type,
EPacketFlags flags,
bool generateChecksums,
int checksummedPartCount,
TPacketId packetId,
TSharedRefArray message) = 0;
virtual TMutableRef GetFragment() = 0;
virtual bool IsFragmentOwned() const = 0;
virtual void NextFragment() = 0;
virtual bool IsFinished() const = 0;
};
struct IPacketTranscoderFactory
{
virtual ~IPacketTranscoderFactory() = default;
virtual std::unique_ptr<IPacketDecoder> CreateDecoder(
const NLogging::TLogger& logger,
bool verifyChecksum) const = 0;
virtual std::unique_ptr<IPacketEncoder> CreateEncoder(
const NLogging::TLogger& logger) const = 0;
virtual bool SupportsHandshakes() const = 0;
};
////////////////////////////////////////////////////////////////////////////////
IPacketTranscoderFactory* GetYTPacketTranscoderFactory();
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NBus
|