SourceFlow.Cloud.GCP 2.0.0-beta.1

This is a prerelease version of SourceFlow.Cloud.GCP.
dotnet add package SourceFlow.Cloud.GCP --version 2.0.0-beta.1
                    
NuGet\Install-Package SourceFlow.Cloud.GCP -Version 2.0.0-beta.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SourceFlow.Cloud.GCP" Version="2.0.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SourceFlow.Cloud.GCP" Version="2.0.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="SourceFlow.Cloud.GCP" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SourceFlow.Cloud.GCP --version 2.0.0-beta.1
                    
#r "nuget: SourceFlow.Cloud.GCP, 2.0.0-beta.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SourceFlow.Cloud.GCP@2.0.0-beta.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SourceFlow.Cloud.GCP&version=2.0.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=SourceFlow.Cloud.GCP&version=2.0.0-beta.1&prerelease
                    
Install as a Cake Tool

SourceFlow.Cloud.GCP

Google Cloud integration for distributed command and event processing

NuGet License

Overview

SourceFlow.Cloud.GCP extends the SourceFlow.Net framework with Google Cloud integration, enabling distributed command and event processing using Google Cloud Pub/Sub and Cloud KMS. The fluent bus API is identical to the AWS and Azure providers โ€” only the backing services change.

Google Cloud Pub/Sub has only topics and subscriptions (no separate queues). A command "queue" is modelled as a topic plus a pull subscription; an event "topic" is a topic plus a pull subscription per subscriber.

Key Features:

  • ๐Ÿš€ Pub/Sub command dispatching (publish to topics, pull from subscriptions)
  • ๐Ÿ“ข Pub/Sub event publishing with per-subscriber pull subscriptions
  • ๐Ÿ” Cloud KMS envelope encryption for sensitive data
  • โš™๏ธ Fluent bus configuration API
  • ๐Ÿ”„ Automatic resource provisioning (topics + subscriptions)
  • ๐Ÿ“Š Built-in health checks and OpenTelemetry metrics
  • ๐Ÿงช Pub/Sub emulator support for local development

Installation

dotnet add package SourceFlow.Cloud.GCP

Prerequisites: SourceFlow โ‰ฅ 2.0.0, Google Cloud SDK / Application Default Credentials, .NET 8.0 / 9.0 / 10.0.


Quick Start

using SourceFlow.Cloud.GCP;

// Register SourceFlow core
services.UseSourceFlow(typeof(Program).Assembly);

// Configure Google Cloud Pub/Sub messaging
services.UseSourceFlowGcp(
    options => { options.ProjectId = "my-project"; },
    bus => bus
        .Send
            .Command<CreateOrderCommand>(q => q.Queue("orders"))
            .Command<ProcessPaymentCommand>(q => q.Queue("payments"))
        .Raise
            .Event<OrderCreatedEvent>(t => t.Topic("order-events"))
            .Event<PaymentProcessedEvent>(t => t.Topic("payment-events"))
        .Listen.To
            .CommandQueue("orders")
            .CommandQueue("payments")
        .Subscribe.To
            .Topic("order-events")
            .Topic("payment-events"));

This registers GCP dispatchers, configures routing, starts the Pub/Sub pull listeners, and automatically provisions topics and subscriptions at startup.


Configuration Options

Option Type Default Description
ProjectId string (required) Google Cloud project that owns the topics/subscriptions
EnableCommandRouting bool true Enable command dispatching to topics
EnableEventRouting bool true Enable event publishing to topics
EnableCommandListener bool true Enable the command pull listener
EnableEventListener bool true Enable the event pull listener
MaxMessagesPerPull int 10 Messages requested per pull
AckDeadlineSeconds int 60 Ack deadline applied to subscriptions at bootstrap
SubscriptionSuffix string -sub Suffix used to derive a subscription id from a name

Resource Provisioning

The GcpBusBootstrapper runs as an IHostedService at startup and idempotently creates:

  • Topics โ€” one per command queue name and per event topic name.
  • Pull subscriptions โ€” {name}-sub for each listening command queue and each subscribed event topic.

All operations tolerate AlreadyExists, so it is safe to run on every startup.


Message Encryption (Cloud KMS)

services.AddSingleton(new GcpKmsOptions
{
    KeyName = "projects/my-project/locations/global/keyRings/my-ring/cryptoKeys/my-key"
});
services.AddSingleton<IMessageEncryption, GcpKmsMessageEncryption>();

Envelope encryption: a random 256-bit data key encrypts the payload with AES-256-GCM, and Cloud KMS wraps (encrypts) the data key. Cloud KMS has no GenerateDataKey operation, so the data key is generated locally and wrapped via the KMS Encrypt call.


Local Development (Pub/Sub emulator)

gcloud beta emulators pubsub start --host-port=localhost:8085
export PUBSUB_EMULATOR_HOST=localhost:8085

The client libraries auto-detect PUBSUB_EMULATOR_HOST (via EmulatorDetection.EmulatorOrProduction). The bootstrapper creates topics/subscriptions in the emulator at startup โ€” no manual setup required.


Idempotency

  • In-memory (single instance) โ€” registered by default as a singleton with a background cleanup service.
  • SQL-based (multi-instance / production) โ€” install SourceFlow.Stores.EntityFramework and call services.AddSourceFlowIdempotency(connectionString) before UseSourceFlowGcp(...).

Monitoring

  • Activity/Meter source: SourceFlow.Cloud.GCP (gcp.pubsub.commands.dispatched, gcp.pubsub.events.published).
  • Health check: registered automatically; verifies Pub/Sub connectivity by listing topics in the project.

License

MIT โ€” see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0-beta.1 44 6/26/2026

v2.0.0 - Initial release with production-ready Google Cloud integration.
     - Pub/Sub command dispatching: publish to topics, pull from subscriptions.
     - Pub/Sub event publishing: topic fan-out to per-service pull subscriptions.
     - Bus bootstrapper: IHostedService that auto-provisions topics and subscriptions at startup.
     - Security: Cloud KMS envelope encryption for messages.
     - Health checks: IHealthCheck implementation for the Pub/Sub endpoint.
     - Local development: Pub/Sub emulator support via PUBSUB_EMULATOR_HOST.
     - Observability: OpenTelemetry metrics across command and event flows.
     - Depends on SourceFlow.Net 2.0.0.