paulgb / are-we-google-cloud-yet

A listing of Rust crates for use with Google Cloud

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Are We Google Cloud Yet?

A collection of Rust packages related to the Google Cloud Platform, in the spirit of Are We X Yet.

Stars ⭐ indicate my preferred stack.

Considerations

Authentication strategy

Requests to Google Cloud services (both REST and gRPC) require a bearer Authorization header. This token is an expiring token, typically associated with a service account.

For code running in a Google VM (e.g. Compute Engine, Cloud Run, Cloud Build), it's possible to obtain the token for a service account using the metadata service, a special REST service available only inside this environment.

Otherwise, you can download a service account JSON file and use that to generate temporary tokens.

Many libraries are designed for the JSON-based approach and may require it even when running in environments where the metadata service would be available.

Just because a service has an API spec doesn't mean that the specified API is generally available to users. In particular, cloud storage is only generally available through a REST API even though a gRPC spec exists.

RPC protocol

Google Cloud APIs are all specified as gRPC interfaces, which are implemented as both gRPC and REST APIs. For the most part, there is a 1:1 correspondence between the REST and gRPC APIs, but it's not perfect. I prefer gRPC APIs, in part because they seem to back the official clients and be higher priority to Google.

Async runtime

Unless otherwise noted, the libraries below target asynchronous Rust. The stack is pretty consistent across crates: tokio as the runtime, hyper as an HTTP client, tonic for gRPC.

Authentication

gouth

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

Synchronous auto-renewed tokens.

google-authz

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

Asynchronous auto-renewed tokens.

yup-oauth2

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

RPC

googapis

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

Auto-generated Rust bindings to gRPC APIs based on tonic. No direct support for authentication; instead, tonic clients can be wrapped in middleware for authentication. Single crate with each API behind a feature flag.

google-apis-rs

GitHub Repo stars GitHub commit activity GitHub contributors

Auto-generated Rust bindings to the REST APIs based on hyper. One crate per API; see list of crates. Uses yup-oauth2 for authentication.

google-cloud

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

Idiomatic Rust bindings for some GCP services, including storage, based on gRPC APIs and tonic. Only supports JSON service account authentication.

Storage

Google Cloud Storage is Google's blob store, roughly equivalent to Amazon S3. Although a gRPC API spec exists, it is not (as far as I can tell) available to regular users outside of Google.

cloud-storage

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

Only supports JSON service account authentication (file or directly through non-standard env vars).

cloud-storage-lite

GitLab link crates.io docs.rs

Minimal API, for bucket-scoped access; built in service account authentication (standard env var) and pluggable.

Observability

Google Cloud Platform attempts to parse emitted log lines as JSON, which are allowed to contain both arbitrary key/values and well-known keys like “severity”. Libraries exist for integrating a number of popular logging/telemetry crates to emit this format.

This functionality originally came from a company Google acquired called Stackdriver. Officially, that branding has been phased out in favor of Google Cloud Operations Suite.

tracing-stackdriver

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

A tracing subscriber for stackdriver. Prints logs to stderr.

stackdriver-logger

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

A log subscriber for stackdriver. Prints logs to stderr.

opentelemetry-stackdriver

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

OpenTelemetry exporter for stackdriver. Writes logs over gRPC.

Database

Confusingly, there are several similarly-named databases under the Google Cloud Platform umbrella:

  • Firestore
  • Firebase
  • Datastore

Firestore is the database Google gently steers you towards for new projects, but I haven't seen any indication that the others are going away.

tiny-firestore-odm

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

A simple object-document mapper built on firestore-serde.

firestore-serde

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

Conversion between native Rust types and Firestore Values using Serde. For use with the googapis interface to Firestore.

Compute

gce-meta

GitHub Repo stars crates.io docs.rs GitHub commit activity GitHub contributors

Access to metadata for VMs running on GCP.

About

A listing of Rust crates for use with Google Cloud