visionai:: StreamSender
#include <streams.h>
StreamSender
is the client through which users send Packet
s to a stream.
Summary
Each instance of the StreamSender
represents a single connection to a specific stream. Once created, the user may repeatedly call Send
with new Packet
s that they want to send to the stream.
Example - Repeatedly sending Packet
s to a specific stream.
// First populate the options. StreamSender::Options options; options.service_connection_options = ...; options.stream_id = "my-stream"; // Create an instance of the `StreamSender`. auto stream_sender_statusor = StreamSender::Create(options); if (!stream_sender.ok()) { // An error occurred during the setup of the sender. // You can fix the problem and try again. } auto stream_sender = std::move(*stream_sender_statusor); // Now you can repeatedly send Packets. while (true) { // Get a new packet from some function or generation mechanism. Packet p = SomeFunctionThatGetsNewPacketsToSend(); auto status = stream_sender->Send(std::move(p)); if (!status.ok()) { // An error occurred. // To retry, you must create a new instance of the sender. } } // When there are no more packets to send, remember to destroy the sender. stream_sender->reset();
Constructors and Destructors |
|
---|---|
StreamSender()
|
|
StreamSender(const StreamSender &)
|
|
~StreamSender()
|
Public static functions |
|
---|---|
Create(const Options &)
|
absl::StatusOr< std::unique_ptr< StreamSender > >
Create a readily usable instance of a
StreamSender . |
Public functions |
|
---|---|
Send(Packet packet)
|
absl::Status
Send the given
packet to a stream. |
Send(Packet packet, absl::Duration timeout)
|
absl::Status
Send the given
packet to a stream with a timeout . |
operator=(const StreamSender &)=delete
|
Structs |
|
---|---|
visionai:: |
Options to configure the |
Public static functions
Create
absl::StatusOr< std::unique_ptr< StreamSender > > Create( const Options & )
Create a readily usable instance of a StreamSender
.
Public functions
Send
absl::Status Send( Packet packet )
Send the given packet
to a stream.
Returns OK on success. Otherwise, returns an error status.
To retry on a case of failure, you must create a new instance of the StreamSender
and Send
through that.
The first overload blocks until the status of the Send
is known. The second overload blocks up to timeout
before returning CANCELLED.
Send
absl::Status Send( Packet packet, absl::Duration timeout )
Send the given packet
to a stream with a timeout
.
Returns OK on success. Otherwise, returns an error status.
To retry on a case of failure, you must create a new instance of the StreamSender
and Send
through that.
The first overload blocks until the status of the Send
is known. The second overload blocks up to timeout
before returning CANCELLED.
StreamSender
StreamSender()=default
StreamSender
StreamSender( const StreamSender & )=delete
operator=
StreamSender & operator=( const StreamSender & )=delete
~StreamSender
~StreamSender()=default