Struct hedwig::publish::GooglePubSubPublisher [−][src]
pub struct GooglePubSubPublisher<C> { /* fields omitted */ }
publish
and google
only.Expand description
A publisher that uses the Google Cloud Pub/Sub service as a message transport
Examples
async {
let google_project =
std::env::var("GOOGLE_CLOUD_PROJECT").unwrap();
let google_credentials = std::env::var("GOOGLE_APPLICATION_CREDENTIALS").unwrap();
let secret = yup_oauth2::read_service_account_key(google_credentials)
.await
.expect("$GOOGLE_APPLICATION_CREDENTIALS is not a valid service account key");
let client = hyper::Client::builder().build(hyper_tls::HttpsConnector::new());
let authenticator = yup_oauth2::ServiceAccountAuthenticator::builder(secret)
.hyper_client(client.clone())
.build()
.await
.expect("could not create an authenticator");
let publisher = hedwig::publish::GooglePubSubPublisher::new(
"rust_publisher".into(),
google_project.into(),
client,
authenticator
);
Ok::<_, Box<dyn std::error::Error>>(publisher)
};
Implementations
pub fn new(
identifier: Cow<'static, str>,
google_cloud_project: Cow<'static, str>,
client: Client<C>,
authenticator: Authenticator<C>
) -> GooglePubSubPublisher<C>
pub fn new(
identifier: Cow<'static, str>,
google_cloud_project: Cow<'static, str>,
client: Client<C>,
authenticator: Authenticator<C>
) -> GooglePubSubPublisher<C>
Create a new Google Cloud Pub/Sub publisher
pub fn with_endpoint(
identifier: Cow<'static, str>,
google_cloud_project: Cow<'static, str>,
client: Client<C>,
authenticator: Option<Authenticator<C>>,
endpoint: Uri
) -> GooglePubSubPublisher<C>
pub fn with_endpoint(
identifier: Cow<'static, str>,
google_cloud_project: Cow<'static, str>,
client: Client<C>,
authenticator: Option<Authenticator<C>>,
endpoint: Uri
) -> GooglePubSubPublisher<C>
Create a new Google Cloud Pub/Sub publisher pointed at a specific endpoint.
This could be useful for running against an emulator, or for targeting a particular region’s endpoint.
The authenticator is also made optional for this constructor, for use in auth-less contexts such as emulators.
Trait Implementations
type MessageError = GooglePubSubError
type MessageError = GooglePubSubError
The error that this publisher returns when publishing of a message fails.
The stream of results that the publish
method returns.
fn publish<'a, I>(&self, topic: Topic, messages: I) -> Self::PublishStream where
I: Iterator<Item = &'a ValidatedMessage>,
fn publish<'a, I>(&self, topic: Topic, messages: I) -> Self::PublishStream where
I: Iterator<Item = &'a ValidatedMessage>,
Publish a batch of messages. Read more
Auto Trait Implementations
impl<C> !RefUnwindSafe for GooglePubSubPublisher<C>
impl<C> Send for GooglePubSubPublisher<C> where
C: Send + Sync,
impl<C> Sync for GooglePubSubPublisher<C> where
C: Send + Sync,
impl<C> Unpin for GooglePubSubPublisher<C> where
C: Unpin,
impl<C> !UnwindSafe for GooglePubSubPublisher<C>
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