Skip to main content

fatal_open

Function fatal_open 

Source
pub fn fatal_open(status: &Status) -> Option<String>
Expand description

Whether the refusal to open a stream is final: a repeat will not help, so the supervisor stops and reports it. Some(reason) for a rejected token (Unauthenticated), no permission (PermissionDenied) and the limit of open streams (80001, streams_limit). Everything else (the network, Unavailable, a rate limit, the lifetime limit 80005) is worth another try.

The status is read with map_status, as every other answer of the broker.

§Examples

use brokapi_tbank::stream::fatal_open;
use tonic::Status;

assert!(fatal_open(&Status::unauthenticated("40003")).is_some());
assert!(fatal_open(&Status::resource_exhausted("80001")).is_some());
assert!(fatal_open(&Status::unavailable("down")).is_none());
assert!(fatal_open(&Status::resource_exhausted("80002")).is_none());