Stackship.Infrastructure.Module
1.0.12
dotnet add package Stackship.Infrastructure.Module --version 1.0.12
NuGet\Install-Package Stackship.Infrastructure.Module -Version 1.0.12
<PackageReference Include="Stackship.Infrastructure.Module" Version="1.0.12" />
<PackageVersion Include="Stackship.Infrastructure.Module" Version="1.0.12" />
<PackageReference Include="Stackship.Infrastructure.Module" />
paket add Stackship.Infrastructure.Module --version 1.0.12
#r "nuget: Stackship.Infrastructure.Module, 1.0.12"
#:package Stackship.Infrastructure.Module@1.0.12
#addin nuget:?package=Stackship.Infrastructure.Module&version=1.0.12
#tool nuget:?package=Stackship.Infrastructure.Module&version=1.0.12
Stackship.Infrastructure.Module
Stackship.Infrastructure.Module is a reusable SDK that helps Stackship microservices register themselves with the Stackship platform. It wires up authentication, dynamic module registration, heartbeat monitoring, and graceful shutdown so your service can focus on business logic.
Features
- Client credentials – obtain and cache bearer tokens for talking to the Stackship API.
- Dynamic module registration – advertise your module key, display name, base URL, and supported resource types.
- Automatic heartbeats – keep the backend informed that the module is healthy; configurable intervals and timeouts.
- Graceful teardown – optional auto-unregister on shutdown to clean up routing entries.
- HTTP proxy compatibility – exposes the metadata required for the Stackship gateway to route resource-scoped requests.
Getting started
Add the package
dotnet add package Stackship.Infrastructure.ModuleAlternatively, reference the project directly from this repository.
Configure your module – add a
Stackshipsection toappsettings.json(or another configuration source):"Stackship": { "BackendBaseUrl": "https://localcloud-api", "Key": "apps", "DisplayName": "Applications", "ResourceTypes": ["apps"], "BaseUrl": "https://module-apps", "Keycloak": { "Url": "https://auth.stackship.local", "Realm": "stackship", "ClientId": "module-apps", "ClientSecret": "<client-secret>", "Audience": "stackship-kubernetes-client" } }Register services – in
Program.cs/ the DI setup, bind the options and register the hosted service:builder.Services.AddHttpContextAccessor(); builder.Services.AddStackshipModule(builder.Configuration.GetSection("Stackship"));The extension validates the configuration on startup and automatically registers the module when the host begins running.
Configuration reference
| Setting | Description |
|---|---|
BackendBaseUrl |
Base URL of the Stackship API. Requests are issued to internal/modules/* endpoints. |
Key |
Unique identifier for the module. Must match the backend allow-list. |
DisplayName |
Human-friendly name shown in the platform. |
ResourceTypes |
One or more resource type strings (e.g., "apps", "databases") that this module manages. |
BaseUrl |
Public URL of the module service; the gateway proxies matching requests here. |
Keycloak.Url / Realm / ClientId / ClientSecret |
Keycloak client credentials used to obtain access tokens. |
Keycloak.Audience |
Optional audience claim requested when fetching tokens. |
HeartbeatInterval |
(Optional) How often to send heartbeats; default 30s. Must be shorter than the timeout. |
HeartbeatTimeout |
(Optional) Advertised timeout to the backend; minimum 10s. |
AutoUnregisterOnShutdown |
Unregister automatically on host shutdown (default true). |
RegistrationRetryInterval |
Delay between failed registration attempts (default 5s). |
HttpTimeout |
Timeout used for backend and Keycloak HTTP calls (default 15s). |
Lifecycle
- Startup –
StackshipModuleRegistrationHostedServiceregisters the module against the Stackship API and begins the heartbeat loop. - Heartbeats – periodic POSTs keep the module marked as
Active. Missing heartbeats eventually mark the module as inactive and remove routing entries. - Shutdown – if
AutoUnregisterOnShutdownistrue, the hosted service sends a DELETE request so the gateway stops routing traffic to the module immediately.
Local development tips
- Ensure
IHttpContextAccessoris registered; the extension throws if it is missing. - Use the sample module in
Stackship.Module.FunctionsManageras a reference implementation. - When running without the full Stackship backend, consider mocking the registration endpoints or disabling the hosted service.
Questions or improvements? Let the Stackship team know and keep modules healthy!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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. |
-
net9.0
- Google.Protobuf (>= 3.32.0)
- Grpc.Core.Api (>= 2.71.0)
- Grpc.Net.Client (>= 2.71.0)
- Grpc.Net.ClientFactory (>= 2.71.0)
- Json.More.Net (>= 2.1.0)
- LocalCloud.Core (>= 1.0.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 9.0.9)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.EntityFrameworkCore (>= 9.0.9)
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.9)
- Microsoft.Extensions.Hosting.Abstractions (>= 9.0.9)
- Microsoft.Extensions.Http (>= 9.0.9)
- Microsoft.Extensions.Options (>= 9.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.