Enum hedwig::publish::GooglePubSubError [−][src]
#[non_exhaustive]
pub enum GooglePubSubError {
Show 14 variants
GetAuthToken(Arc<Error>),
PostMessages(Arc<Error>),
ConstructRequestUri(Arc<InvalidUri>),
ConstructRequest(Arc<Error>),
ResponseStatus(Option<Arc<PubSubPublishError>>, StatusCode),
ResponseParse(Arc<Error>),
ResponseBodyReceive(Arc<Error>),
MessageTooManyHeaders,
MessageHeaderKeysTooLarge,
MessageHeaderKeysReserved(Arc<str>),
MessageHeaderValuesTooLarge,
MessageDataTooLong,
MessageTimestampTooOld(SystemTimeError),
SerializeMessageData(Arc<Error>),
}
publish
and google
only.Expand description
Error messages that occur when publishing to Google PubSub.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
Could not get authentication token.
Could not POST the request with messages.
ConstructRequestUri(Arc<InvalidUri>)
Could not construct the request URI.
Tuple Fields of ConstructRequestUri
0: Arc<InvalidUri>
Could not construct the request.
ResponseStatus(Option<Arc<PubSubPublishError>>, StatusCode)
Publish request failed with a bad HTTP status code.
Tuple Fields of ResponseStatus
0: Option<Arc<PubSubPublishError>>
1: StatusCode
Could not parse the response body.
Could not receive the response body.
Message contains too many headers.
Message contains a header key that’s too large.
Message contains a header with {0} key which is reserved.
Message contains a header value that’s too large.
Encoded message data is too long.
MessageTimestampTooOld(SystemTimeError)
Message timestamp is too far in the past.
Tuple Fields of MessageTimestampTooOld
Could not serialize message data.
Implementations
Can this error be considered recoverable.
Some examples of transient errors include errors such as failure to make a network request or authenticate with the API endpoint.
In these instances there is a good chance that retrying publishing of a message may succeed.
Examples
This function is useful when deciding whether to re-queue message for publishing.
use futures_util::stream::StreamExt;
let publisher: GooglePubSubPublisher<hyper::client::HttpConnector> = unimplemented!();
let mut batch = hedwig::publish::PublishBatch::new();
// add messages
let mut stream = batch.publish(&publisher);
let mut next_batch = hedwig::publish::PublishBatch::new();
async {
while let Some(result) = stream.next().await {
match result {
(Ok(id), _, msg) => {
println!("message {} published successfully: {:?}", msg.uuid(), id);
}
(Err(e), topic, msg) if e.is_transient() => {
// Retry
next_batch.push(topic, msg);
}
(Err(e), _, msg) => {
eprintln!("failed to publish {}: {}", msg.uuid(), e);
}
}
}
};
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for GooglePubSubError
impl Send for GooglePubSubError
impl Sync for GooglePubSubError
impl Unpin for GooglePubSubError
impl !UnwindSafe for GooglePubSubError
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more