All Projects → kayleg → cloud-pubsub

kayleg / cloud-pubsub

Licence: MIT license
Google Cloud PubSub client in rust

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to cloud-pubsub

souls
SOULs 🔥 Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, RBS/Steep, Active Record, RSpec, RuboCop, and Google Cloud.
Stars: ✭ 327 (+1111.11%)
Mutual labels:  google-cloud, pubsub
iris3
An upgraded and improved version of the Iris automatic GCP-labeling project
Stars: ✭ 38 (+40.74%)
Mutual labels:  google-cloud, pubsub
emulator-tools
Google Cloud BigTable and PubSub emulator tools to make development a breeze
Stars: ✭ 16 (-40.74%)
Mutual labels:  google-cloud, pubsub
Rele
Easy to use Google Pub/Sub
Stars: ✭ 164 (+507.41%)
Mutual labels:  google-cloud, pubsub
websub-hub
A WebSub Hub implementation in Node.js
Stars: ✭ 44 (+62.96%)
Mutual labels:  pubsub
count
Comparing serverless platforms
Stars: ✭ 27 (+0%)
Mutual labels:  google-cloud
notification
OST Notification helps publish critical events for cross platform communications
Stars: ✭ 20 (-25.93%)
Mutual labels:  pubsub
smartacus-mqtt-broker
smartacus-mqtt-broker is a Java-based open source MQTT broker that fully supports MQTT 3.x .Using Netty 4.1.37
Stars: ✭ 25 (-7.41%)
Mutual labels:  pubsub
astrobase
Simple, fast, and secure deployments anywhere.
Stars: ✭ 47 (+74.07%)
Mutual labels:  google-cloud
dry-events
Pub/sub system
Stars: ✭ 102 (+277.78%)
Mutual labels:  pubsub
payload
A javascript single page application (SPA) driver for REST API payload management.
Stars: ✭ 16 (-40.74%)
Mutual labels:  pubsub
spanner-bench
Google Cloud Spanner Query Planner Benchmarking
Stars: ✭ 24 (-11.11%)
Mutual labels:  google-cloud
google-kubernetes-engine-plugin
The Google Kubernetes Engine (GKE) Plugin allows you to deploy build artifacts to Kubernetes clusters running in GKE with Jenkins.
Stars: ✭ 33 (+22.22%)
Mutual labels:  google-cloud
deploy-cloudrun
This action deploys your container image to Cloud Run.
Stars: ✭ 238 (+781.48%)
Mutual labels:  google-cloud
go-msg
Pub/Sub Message Primitives for Go
Stars: ✭ 44 (+62.96%)
Mutual labels:  pubsub
fastapi websocket pubsub
A fast and durable Pub/Sub channel over Websockets. FastAPI + WebSockets + PubSub == ⚡ 💪 ❤️
Stars: ✭ 255 (+844.44%)
Mutual labels:  pubsub
GoogleCloudLogging
Swift (Darwin) library for logging application events in Google Cloud.
Stars: ✭ 24 (-11.11%)
Mutual labels:  google-cloud
datacatalog-tag-manager
Python package to manage Google Cloud Data Catalog tags, loading metadata from external sources -- currently supports the CSV file format
Stars: ✭ 17 (-37.04%)
Mutual labels:  google-cloud
gocloud
☁️ Go API for open cloud
Stars: ✭ 113 (+318.52%)
Mutual labels:  google-cloud
K8s-Cluster-Provisioner-GCP-Terrafrom
This repo will seamlessly setup self managed Kubernetes cluster in GCP using Terraform and Kubespray.
Stars: ✭ 17 (-37.04%)
Mutual labels:  google-cloud

cloud-pubsub

Provides methods to consume messages from Google PubSub using Futures and Hyper.

Authentication

Authentication is provided by rust-goauth. The BaseClient expects to receive the path to the file containing your Google Cloud service account JSON key.

Token Renewal

The JWT token has a short life time and needs to be renewed periodically for long lived processes.

There is a provided helper which will renew the token every 15 mins:

let pubsub = match BaseClient::create(config.google_application_credentials) {
    Err(e) => panic!("Failed to initialize pubsub: {}", e),
        Ok(p) => p,
};

tokio::run(lazy(move || {
    pubsub.spawn_token_renew();
}))

Env Config

Envy is an excellent way to load your config.

#[derive(Deserialize)]
struct Config {
    pubsub_subscription: String,
    google_application_credentials: String,
}


fn main() {
    let parsed_env = envy::from_env::<Config>();
    if let Err(e) = parsed_env {
        eprintln!("ENV is not valid: {}", e);
        std::process::exit(1);
    }
    let config = parsed_env.unwrap();

    let pubsub = match BaseClient::create(config.google_application_credentials) {
        Err(e) => panic!("Failed to initialize pubsub: {}", e),
        Ok(p) => p,
    };
}

Log Config

In order to produce log output, executables have to use a logger implementation compatible with the log facade. There are many available implementations to chose from, for example:

env_logger is an excellent way to log in your executables.

[dependencies]
log = "0.4"
env_logger = "0.7"
fn main() {
    env_logger::init();

    info!("starting up");

    // ...
}

Subscribing

Connecting to existing subscription

let sub = my_client.subscribe("subscription-name")

Subscribing to a topic

When subscribing to a topic, a random subscription name will be generated. To prevent dangling subscriptions, you need to explicitly call subscription.destroy().

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].