SourceFlow.Cloud.GCP
2.0.0-beta.1
dotnet add package SourceFlow.Cloud.GCP --version 2.0.0-beta.1
NuGet\Install-Package SourceFlow.Cloud.GCP -Version 2.0.0-beta.1
<PackageReference Include="SourceFlow.Cloud.GCP" Version="2.0.0-beta.1" />
<PackageVersion Include="SourceFlow.Cloud.GCP" Version="2.0.0-beta.1" />
<PackageReference Include="SourceFlow.Cloud.GCP" />
paket add SourceFlow.Cloud.GCP --version 2.0.0-beta.1
#r "nuget: SourceFlow.Cloud.GCP, 2.0.0-beta.1"
#:package SourceFlow.Cloud.GCP@2.0.0-beta.1
#addin nuget:?package=SourceFlow.Cloud.GCP&version=2.0.0-beta.1&prerelease
#tool nuget:?package=SourceFlow.Cloud.GCP&version=2.0.0-beta.1&prerelease
SourceFlow.Cloud.GCP
Google Cloud integration for distributed command and event processing
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}-subfor 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.EntityFrameworkand callservices.AddSourceFlowIdempotency(connectionString)beforeUseSourceFlowGcp(...).
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 | Versions 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. |
-
net10.0
- Google.Cloud.Kms.V1 (>= 3.16.0)
- Google.Cloud.PubSub.V1 (>= 3.17.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.0)
- Microsoft.Extensions.Hosting (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- SourceFlow.Net (>= 2.0.0)
-
net8.0
- Google.Cloud.Kms.V1 (>= 3.16.0)
- Google.Cloud.PubSub.V1 (>= 3.17.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.0)
- Microsoft.Extensions.Hosting (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- SourceFlow.Net (>= 2.0.0)
-
net9.0
- Google.Cloud.Kms.V1 (>= 3.16.0)
- Google.Cloud.PubSub.V1 (>= 3.17.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.0)
- Microsoft.Extensions.Hosting (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- SourceFlow.Net (>= 2.0.0)
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.