AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
anch::rest::ThriftTransport Class Reference

#include <thriftTransport.hpp>

Inheritance diagram for anch::rest::ThriftTransport:
Collaboration diagram for anch::rest::ThriftTransport:

Public Member Functions

 ThriftTransport (anch::rest::Client &client, std::string path, anch::codec::ThriftProtocol protocol=anch::codec::ThriftProtocol::BINARY)
virtual bool isOpen () const override
virtual void open () override
virtual void close () override
uint32_t read (uint8_t *buffer, uint32_t length)
void write (const uint8_t *buffer, uint32_t length)
virtual void flush () override

Detailed Description

Thrift transport over an anch-rest client (header only: link anch::rest-client ): calls are sent with POST path on client base URL (client filters, authentication and transport apply), to an API with installThrift or any Thrift HTTP server. Clients generated by thrift –gen cpp use it as is:

auto transport = std::make_shared<anch::rest::ThriftTransport>(client, "/thrift/pets"); // rest/thriftTransport.hpp
pets::Pet pet;
pets.getPet(pet, 1); // declared exceptions are raised by the generated client

The protocol given to the transport sets the request content type (it has to be the one of the client protocol). Responses with status greater or equal to 400 raise HttpError . A transport is used by one client at a time.

Author
Vincent Lachenal
Since
0.2

Constructor & Destructor Documentation

◆ ThriftTransport()

anch::rest::ThriftTransport::ThriftTransport ( anch::rest::Client & client,
std::string path,
anch::codec::ThriftProtocol protocol = anch::codec::ThriftProtocol::BINARY )

ThriftTransport constructor

Parameters
clientthe anch-rest client (it has to outlive the transport)
paththe service path
protocolthe protocol of the Thrift client (request content type)

Member Function Documentation

◆ close()

virtual void anch::rest::ThriftTransport::close ( )
overridevirtual

Nothing to close

◆ flush()

virtual void anch::rest::ThriftTransport::flush ( )
overridevirtual

Send request and receive response

Exceptions
HttpErrorwhen response status is greater or equal to 400
TransportErroron network error

◆ isOpen()

virtual bool anch::rest::ThriftTransport::isOpen ( ) const
overridevirtual

Transport is always open (connections are managed by the anch-rest transport)

Returns
true

◆ open()

virtual void anch::rest::ThriftTransport::open ( )
overridevirtual

Nothing to open

◆ read()

uint32_t anch::rest::ThriftTransport::read ( uint8_t * buffer,
uint32_t length )

Read response

Parameters
bufferthe buffer to fill
lengththe maximum length
Returns
the number of bytes read, 0 at the end of the response

◆ write()

void anch::rest::ThriftTransport::write ( const uint8_t * buffer,
uint32_t length )

Write request

Parameters
bufferthe data
lengththe data length

The documentation for this class was generated from the following file: