1 unstable release
0.1.0 | Oct 21, 2019 |
---|
#10 in #google-cloud-platform
21KB
365 lines
gcp-pubsub
A crate that acts as a HTTP client to publish and read messages from Google Cloud Platform's PubSub.
Usage
Create a client
Authentication is provided by rust-goauth, which expects a path to the file containing your Google Cloud service account JSON key.
let google_credentials = std::env::var("GOOGLE_PUBSUB_CREDENTIALS").unwrap();
let mut client = gcp_pubsub::Client::new(credentials);
Create a topic
let topic = client.create_topic("my-topic").await;
Publish a message
#[derive(Serialize, Default)]
struct Foo {
pub a: String,
}
let result: Result<(), Error> = topic.publish(Foo::default()).await;
Read messages
let subscription = topic.create_subscription().await.unwrap();
let messages : Result<Vec<gcp_pubsub::Message>, Error> = subscription.pull().await;
Dependencies
~24MB
~523K SLoC