mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-08-08 09:42:06 +03:00
Getter API of Quic stream priority
Summary: as title Reviewed By: afrind, avasylev Differential Revision: D26744365 fbshipit-source-id: 5c5d104ca76c77f14371c20d6f791fca8d7cfe38
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6f63fa59ca
commit
0b42e07216
@@ -17,6 +17,7 @@
|
||||
#include <quic/codec/Types.h>
|
||||
#include <quic/common/SmallVec.h>
|
||||
#include <quic/state/QuicConnectionStats.h>
|
||||
#include <quic/state/QuicPriorityQueue.h>
|
||||
#include <quic/state/StateData.h>
|
||||
|
||||
#include <chrono>
|
||||
@@ -458,6 +459,12 @@ class QuicSocket {
|
||||
virtual folly::Expected<folly::Unit, LocalErrorCode>
|
||||
setStreamPriority(StreamId id, PriorityLevel level, bool incremental) = 0;
|
||||
|
||||
/**
|
||||
* Get stream priority.
|
||||
*/
|
||||
virtual folly::Expected<Priority, LocalErrorCode> getStreamPriority(
|
||||
StreamId id) = 0;
|
||||
|
||||
/**
|
||||
* ===== Read API ====
|
||||
*/
|
||||
|
@@ -2999,6 +2999,18 @@ QuicTransportBase::setStreamPriority(
|
||||
return folly::unit;
|
||||
}
|
||||
|
||||
folly::Expected<Priority, LocalErrorCode> QuicTransportBase::getStreamPriority(
|
||||
StreamId id) {
|
||||
if (closeState_ != CloseState::OPEN) {
|
||||
return folly::makeUnexpected(LocalErrorCode::CONNECTION_CLOSED);
|
||||
}
|
||||
auto stream = conn_->streamManager->findStream(id);
|
||||
if (!stream) {
|
||||
return folly::makeUnexpected(LocalErrorCode::STREAM_NOT_EXISTS);
|
||||
}
|
||||
return stream->priority;
|
||||
}
|
||||
|
||||
void QuicTransportBase::validateCongestionAndPacing(
|
||||
CongestionControlType& type) {
|
||||
// Fallback to Cubic if Pacing isn't enabled with BBR together
|
||||
|
@@ -323,6 +323,9 @@ class QuicTransportBase : public QuicSocket {
|
||||
PriorityLevel level,
|
||||
bool incremental) override;
|
||||
|
||||
folly::Expected<Priority, LocalErrorCode> getStreamPriority(
|
||||
StreamId id) override;
|
||||
|
||||
/**
|
||||
* Invoke onCanceled on all the delivery callbacks registered for streamId.
|
||||
*/
|
||||
|
@@ -99,6 +99,9 @@ class MockQuicSocket : public QuicSocket {
|
||||
MOCK_METHOD3(
|
||||
setStreamPriority,
|
||||
folly::Expected<folly::Unit, LocalErrorCode>(StreamId, uint8_t, bool));
|
||||
MOCK_METHOD1(
|
||||
getStreamPriority,
|
||||
folly::Expected<Priority, LocalErrorCode>(StreamId));
|
||||
MOCK_METHOD3(
|
||||
setReadCallback,
|
||||
folly::Expected<folly::Unit, LocalErrorCode>(
|
||||
|
@@ -3265,5 +3265,19 @@ TEST_F(QuicTransportTest, GetStreamPacketsTxedMultiplePackets) {
|
||||
Mock::VerifyAndClearExpectations(&lastByteTxCb);
|
||||
}
|
||||
|
||||
TEST_F(QuicTransportTest, PrioritySetAndGet) {
|
||||
auto stream = transport_->createBidirectionalStream().value();
|
||||
EXPECT_EQ(kDefaultPriority, transport_->getStreamPriority(stream).value());
|
||||
transport_->setStreamPriority(stream, 0, false);
|
||||
EXPECT_EQ(Priority(0, false), transport_->getStreamPriority(stream).value());
|
||||
auto nonExistStreamPri = transport_->getStreamPriority(stream + 4);
|
||||
EXPECT_TRUE(nonExistStreamPri.hasError());
|
||||
EXPECT_EQ(LocalErrorCode::STREAM_NOT_EXISTS, nonExistStreamPri.error());
|
||||
transport_->close(folly::none);
|
||||
auto closedConnStreamPri = transport_->getStreamPriority(stream);
|
||||
EXPECT_TRUE(closedConnStreamPri.hasError());
|
||||
EXPECT_EQ(LocalErrorCode::CONNECTION_CLOSED, closedConnStreamPri.error());
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace quic
|
||||
|
@@ -19,7 +19,7 @@ struct Priority {
|
||||
|
||||
Priority(uint8_t l, bool i) : level(l), incremental(i) {}
|
||||
|
||||
bool operator==(Priority other) {
|
||||
bool operator==(Priority other) const noexcept {
|
||||
return level == other.level && incremental == other.incremental;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user