@@ -164,7 +164,8 @@ std::vector<std::uint8_t> encode_subscribe_namespace_message(std::uint64_t reque
164164
165165std::vector<std::uint8_t > encode_subscribe_message (std::uint64_t request_id,
166166 std::string_view track_namespace,
167- std::string_view track_name) {
167+ std::string_view track_name,
168+ std::uint8_t forward) {
168169 std::vector<std::uint8_t > payload = encode_varint (request_id);
169170 const std::vector<std::uint8_t > tuple_len = encode_varint (1 );
170171 const std::vector<std::uint8_t > component_len = encode_varint (track_namespace.size ());
@@ -176,7 +177,7 @@ std::vector<std::uint8_t> encode_subscribe_message(std::uint64_t request_id,
176177 payload.insert (payload.end (), track_name.begin (), track_name.end ());
177178 payload.push_back (0x80 );
178179 payload.push_back (0x01 );
179- payload.push_back (0x01 );
180+ payload.push_back (forward );
180181 const std::vector<std::uint8_t > filter_type = encode_varint (0x03 );
181182 const std::vector<std::uint8_t > start_group = encode_varint (0 );
182183 const std::vector<std::uint8_t > start_object = encode_varint (0 );
@@ -216,11 +217,15 @@ std::vector<std::uint8_t> encode_publish_ok_message(DraftVersion draft, std::uin
216217void queue_subscribe_requests (MockTransport& transport,
217218 DraftVersion draft,
218219 std::string_view track_namespace,
219- std::initializer_list<std::pair<std::uint64_t , std::string>> requests) {
220+ std::initializer_list<std::pair<std::uint64_t , std::string>> requests,
221+ bool include_subscribe_namespace = false ,
222+ std::uint8_t forward = 0 ) {
220223 transport.reads [0 ].push_back (encode_publish_namespace_ok_message (draft, 0 ));
221- transport.reads [0 ].push_back (encode_subscribe_namespace_message (1 , track_namespace));
224+ if (include_subscribe_namespace) {
225+ transport.reads [0 ].push_back (encode_subscribe_namespace_message (1 , track_namespace));
226+ }
222227 for (const auto & [request_id, track_name] : requests) {
223- transport.reads [0 ].push_back (encode_subscribe_message (request_id, track_namespace, track_name));
228+ transport.reads [0 ].push_back (encode_subscribe_message (request_id, track_namespace, track_name, forward ));
224229 }
225230}
226231
@@ -408,9 +413,9 @@ int main() {
408413 materialize_publish_plan (make_span_backed_plan (DraftVersion::kDraft14 ), source_bytes);
409414
410415 status = session.publish (materialized);
411- ok &= expect (status.ok , " expected publish to succeed with announce plus subscribe flow" );
412- ok &= expect (transport.writes .size () == 10 ,
413- " expected setup, namespace, subscribe_namespace_ok, two subscribe_ok, two object streams, two publish_done, namespace_done" );
416+ ok &= expect (status.ok , " expected publish to succeed with relay subscribe flow" );
417+ ok &= expect (transport.writes .size () == 9 ,
418+ " expected setup, namespace, two subscribe_ok, two object streams, two publish_done, namespace_done" );
414419 ok &= expect (!transport.writes [0 ].bytes .empty () && transport.writes [0 ].bytes .front () == 0x20 ,
415420 " expected binary CLIENT_SETUP message type" );
416421 authority.clear ();
@@ -425,21 +430,20 @@ int main() {
425430 ok &= expect (transport.writes [1 ].bytes == std::vector<std::uint8_t >({0x06 , 0x00 , 0x0b , 0x00 , 0x01 , 0x07 , 0x69 , 0x6e ,
426431 0x74 , 0x65 , 0x72 , 0x6f , 0x70 , 0x00 }),
427432 " expected namespace write to use the configured track namespace" );
428- ok &= expect (message_type (transport.writes [2 ].bytes ) == 0x12 , " expected SUBSCRIBE_NAMESPACE_OK" );
429- ok &= expect (message_type (transport.writes [3 ].bytes ) == 0x04 , " expected first SUBSCRIBE_OK" );
430- ok &= expect (transport.writes [4 ].stream_id == 2 , " expected first object stream to be unidirectional stream 2" );
431- ok &= expect (!transport.writes [4 ].bytes .empty () && transport.writes [4 ].bytes .front () == 0x14 ,
433+ ok &= expect (message_type (transport.writes [2 ].bytes ) == 0x04 , " expected first SUBSCRIBE_OK" );
434+ ok &= expect (transport.writes [3 ].stream_id == 2 , " expected first object stream to be unidirectional stream 2" );
435+ ok &= expect (!transport.writes [3 ].bytes .empty () && transport.writes [3 ].bytes .front () == 0x14 ,
432436 " expected first object stream to use a subgroup header with explicit subgroup ID" );
433- ok &= expect (transport.writes [4 ].fin , " expected first object stream write to set FIN" );
434- ok &= expect (message_type (transport.writes [5 ].bytes ) == 0x0b , " expected first PUBLISH_DONE" );
435- ok &= expect (message_type (transport.writes [6 ].bytes ) == 0x04 , " expected second SUBSCRIBE_OK" );
436- ok &= expect (transport.writes [7 ].stream_id == 6 , " expected second object stream to be unidirectional stream 6" );
437- ok &= expect (!transport.writes [7 ].bytes .empty () && transport.writes [7 ].bytes .front () == 0x14 ,
437+ ok &= expect (transport.writes [3 ].fin , " expected first object stream write to set FIN" );
438+ ok &= expect (message_type (transport.writes [4 ].bytes ) == 0x0b , " expected first PUBLISH_DONE" );
439+ ok &= expect (message_type (transport.writes [5 ].bytes ) == 0x04 , " expected second SUBSCRIBE_OK" );
440+ ok &= expect (transport.writes [6 ].stream_id == 6 , " expected second object stream to be unidirectional stream 6" );
441+ ok &= expect (!transport.writes [6 ].bytes .empty () && transport.writes [6 ].bytes .front () == 0x14 ,
438442 " expected second object stream to use a subgroup header with explicit subgroup ID" );
439- ok &= expect (transport.writes [7 ].fin , " expected second object stream write to set FIN" );
440- ok &= expect (message_type (transport.writes [8 ].bytes ) == 0x0b , " expected second PUBLISH_DONE" );
441- ok &= expect (message_type (transport.writes [9 ].bytes ) == 0x09 , " expected PUBLISH_NAMESPACE_DONE" );
442- ok &= expect (transport.writes [9 ].bytes == std::vector<std::uint8_t >({0x09 , 0x00 , 0x09 , 0x01 , 0x07 , 0x69 , 0x6e ,
443+ ok &= expect (transport.writes [6 ].fin , " expected second object stream write to set FIN" );
444+ ok &= expect (message_type (transport.writes [7 ].bytes ) == 0x0b , " expected second PUBLISH_DONE" );
445+ ok &= expect (message_type (transport.writes [8 ].bytes ) == 0x09 , " expected PUBLISH_NAMESPACE_DONE" );
446+ ok &= expect (transport.writes [8 ].bytes == std::vector<std::uint8_t >({0x09 , 0x00 , 0x09 , 0x01 , 0x07 , 0x69 , 0x6e ,
443447 0x74 , 0x65 , 0x72 , 0x6f , 0x70 }),
444448 " expected draft-14 PUBLISH_NAMESPACE_DONE to contain the configured track namespace" );
445449 }
@@ -498,7 +502,7 @@ int main() {
498502 materialize_publish_plan (make_span_backed_plan (DraftVersion::kDraft16 ), source_bytes);
499503 status = draft16_session.publish (draft16_materialized);
500504 ok &= expect (status.ok , " expected draft-16 publish to succeed" );
501- ok &= expect (draft16_transport.writes .size () == 10 , " expected draft-16 announce/ subscribe control/object sequence" );
505+ ok &= expect (draft16_transport.writes .size () == 9 , " expected draft-16 relay subscribe control/object sequence" );
502506 ok &= expect (!draft16_transport.writes [0 ].bytes .empty () && draft16_transport.writes [0 ].bytes .front () == 0x20 ,
503507 " expected draft-16 binary CLIENT_SETUP message type" );
504508 authority.clear ();
@@ -515,16 +519,15 @@ int main() {
515519 0x69 , 0x6e , 0x74 , 0x65 , 0x72 , 0x6f ,
516520 0x70 , 0x00 }),
517521 " expected draft-16 namespace write to use the configured track namespace" );
518- ok &= expect (message_type (draft16_transport.writes [2 ].bytes ) == 0x07 , " expected draft-16 REQUEST_OK" );
519- ok &= expect (message_type (draft16_transport.writes [3 ].bytes ) == 0x04 , " expected first draft-16 SUBSCRIBE_OK" );
520- ok &= expect (draft16_transport.writes [4 ].stream_id == 2 , " expected first draft-16 object stream" );
521- ok &= expect (message_type (draft16_transport.writes [5 ].bytes ) == 0x0b , " expected first draft-16 PUBLISH_DONE" );
522- ok &= expect (message_type (draft16_transport.writes [6 ].bytes ) == 0x04 , " expected second draft-16 SUBSCRIBE_OK" );
523- ok &= expect (draft16_transport.writes [7 ].stream_id == 6 , " expected second draft-16 object stream" );
524- ok &= expect (message_type (draft16_transport.writes [8 ].bytes ) == 0x0b , " expected second draft-16 PUBLISH_DONE" );
525- ok &= expect (message_type (draft16_transport.writes [9 ].bytes ) == 0x09 ,
522+ ok &= expect (message_type (draft16_transport.writes [2 ].bytes ) == 0x04 , " expected first draft-16 SUBSCRIBE_OK" );
523+ ok &= expect (draft16_transport.writes [3 ].stream_id == 2 , " expected first draft-16 object stream" );
524+ ok &= expect (message_type (draft16_transport.writes [4 ].bytes ) == 0x0b , " expected first draft-16 PUBLISH_DONE" );
525+ ok &= expect (message_type (draft16_transport.writes [5 ].bytes ) == 0x04 , " expected second draft-16 SUBSCRIBE_OK" );
526+ ok &= expect (draft16_transport.writes [6 ].stream_id == 6 , " expected second draft-16 object stream" );
527+ ok &= expect (message_type (draft16_transport.writes [7 ].bytes ) == 0x0b , " expected second draft-16 PUBLISH_DONE" );
528+ ok &= expect (message_type (draft16_transport.writes [8 ].bytes ) == 0x09 ,
526529 " expected draft-16 PUBLISH_NAMESPACE_DONE" );
527- ok &= expect (draft16_transport.writes [9 ].bytes == std::vector<std::uint8_t >({0x09 , 0x00 , 0x01 , 0x00 }),
530+ ok &= expect (draft16_transport.writes [8 ].bytes == std::vector<std::uint8_t >({0x09 , 0x00 , 0x01 , 0x00 }),
528531 " expected draft-16 PUBLISH_NAMESPACE_DONE to contain only the request ID" );
529532
530533 const std::vector<std::uint8_t > split_server_setup = encode_server_setup_message ({
0 commit comments