| 647 | class DoPutTestServer : public FlightServerBase { |
| 648 | public: |
| 649 | Status DoPut(const ServerCallContext& context, |
| 650 | std::unique_ptr<FlightMessageReader> reader, |
| 651 | std::unique_ptr<FlightMetadataWriter> writer) override { |
| 652 | descriptor_ = reader->descriptor(); |
| 653 | |
| 654 | if (descriptor_.type == FlightDescriptor::DescriptorType::CMD) { |
| 655 | if (descriptor_.cmd == "TestUndrained") { |
| 656 | // Don't read all the messages |
| 657 | return Status::OK(); |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | int counter = 0; |
| 662 | FlightStreamChunk chunk; |
| 663 | while (true) { |
| 664 | ARROW_ASSIGN_OR_RAISE(chunk, reader->Next()); |
| 665 | if (!chunk.data) break; |
| 666 | if (counter % 2 == 1) { |
| 667 | if (!chunk.app_metadata) { |
| 668 | return Status::Invalid("Expected app_metadata"); |
| 669 | } else if (chunk.app_metadata->ToString() != std::to_string(counter)) { |
| 670 | return Status::Invalid("Expected app_metadata to be ", counter, " but got ", |
| 671 | chunk.app_metadata->ToString()); |
| 672 | } |
| 673 | } else if (chunk.app_metadata) { |
| 674 | return Status::Invalid("Expected no app_metadata"); |
| 675 | } |
| 676 | batches_.push_back(std::move(chunk.data)); |
| 677 | auto buffer = Buffer::FromString(std::to_string(counter)); |
| 678 | RETURN_NOT_OK(writer->WriteMetadata(*buffer)); |
| 679 | counter++; |
| 680 | } |
| 681 | |
| 682 | // Expect a metadata-only message |
| 683 | if (!chunk.app_metadata) { |
| 684 | return Status::Invalid("Expected app_metadata at end of stream (#1)"); |
| 685 | } else if (chunk.app_metadata->ToString() != kExpectedMetadata) { |
| 686 | return Status::Invalid("Expected app_metadata to be ", kExpectedMetadata, |
| 687 | " but got ", chunk.app_metadata->ToString()); |
| 688 | } |
| 689 | |
| 690 | return Status::OK(); |
| 691 | } |
| 692 | |
| 693 | protected: |
| 694 | FlightDescriptor descriptor_; |
nothing calls this directly
no test coverage detected