Nabs.Launchpad.Core.Silo 10.0.213

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Nabs.Launchpad.Core.Silo --version 10.0.213
                    
NuGet\Install-Package Nabs.Launchpad.Core.Silo -Version 10.0.213
                    
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="Nabs.Launchpad.Core.Silo" Version="10.0.213" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nabs.Launchpad.Core.Silo" Version="10.0.213" />
                    
Directory.Packages.props
<PackageReference Include="Nabs.Launchpad.Core.Silo" />
                    
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 Nabs.Launchpad.Core.Silo --version 10.0.213
                    
#r "nuget: Nabs.Launchpad.Core.Silo, 10.0.213"
                    
#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 Nabs.Launchpad.Core.Silo@10.0.213
                    
#: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=Nabs.Launchpad.Core.Silo&version=10.0.213
                    
Install as a Cake Addin
#tool nuget:?package=Nabs.Launchpad.Core.Silo&version=10.0.213
                    
Install as a Cake Tool

Nabs Launchpad Core Silo Library

A .NET 10 library providing Orleans silo hosting capabilities and configuration for distributed computing in the Nabs Launchpad framework.

Overview

The Nabs.Launchpad.Core.Silo library enables hosting Microsoft Orleans silos with pre-configured clustering, persistence, and authorization features. Orleans is a cross-platform framework for building robust, scalable distributed applications using the Virtual Actor Model.

Key Features

  • Orleans Silo Hosting: Complete silo configuration with Azure Table clustering and blob storage persistence
  • Authorization Framework: Built-in grain call authorization with anonymous method support
  • Orleans Dashboard: Integrated dashboard for monitoring grain activity and cluster status
  • Azure Integration: Configured for Azure Table Storage clustering and Azure Blob Storage persistence
  • Entity Framework Integration: SQL Server database connectivity through Aspire
  • Service Defaults: Integration with Nabs Launchpad service configuration standards

Key Components

ProjectExtensions

The main entry point for configuring Orleans silo services:

public static IHostApplicationBuilder AddSiloServices(
    this IHostApplicationBuilder builder, 
    Action<SiloServicesOptions> siloServicesOptionsSetup)

SiloServicesOptions

Configuration options for the Orleans silo:

public class SiloServicesOptions
{
    // Authorization filter configuration
    public List<string> AuthorizationFilterTypePrefixes { get; set; } = [];
    
    // Orleans cluster configuration
    public string ClusterId { get; set; } = "default";
    public string ServiceId { get; set; } = string.Empty;
    
    // Serialization options
    public OrleansSerializationOptions SerializationOptions { get; } = new();
}

AuthorisationFilter

Grain call authorization filter that:

  • Validates user context for protected grain methods
  • Supports anonymous methods via [Anonymous] attribute
  • Applies to grain interfaces matching configured type prefixes

AnonymousAttribute

Attribute to mark grain methods as not requiring authorization:

[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
public class AnonymousAttribute : Attribute

Dependencies

  • Microsoft.Orleans.Server: Core Orleans silo functionality
  • Microsoft.Orleans.Clustering.AzureStorage: Azure Table Storage clustering
  • Microsoft.Orleans.Persistence.AzureStorage: Azure Blob Storage persistence
  • OrleansDashboard: Monitoring and administration dashboard
  • Aspire.Azure.Data.Tables & Aspire.Azure.Storage.Blobs: Azure service integrations
  • Ardalis.Result & Ardalis.Result.FluentValidation: Result pattern support
  • Entity Framework Core SQL Server: Database connectivity

Usage Example

Configuring the Silo

var builder = Host.CreateApplicationBuilder(args);

builder.AddSiloServices(options =>
{
    options.ClusterId = "my-cluster";
    options.ServiceId = "my-service";
    options.AuthorizationFilterTypePrefixes.Add("MyApp.Grains.Interfaces");
    options.SerializationOptions.SupportedPrefixes.Add("MyApp.Models");
});

var app = builder.Build();
await app.RunAsync();

Creating Protected Grains

public interface IUserGrain : IGrainWithStringKey
{
    // Requires authorization
    Task<User> GetUserAsync();
    
    // Anonymous access allowed
    [Anonymous]
    Task<bool> CheckHealthAsync();
}

public class UserGrain : Grain, IUserGrain
{
    public Task<User> GetUserAsync()
    {
        // This method requires a valid UserContext in RequestContext
        var userContext = RequestContext.Get("UserContext");
        // Implementation...
    }
    
    public Task<bool> CheckHealthAsync()
    {
        // This method allows anonymous access
        return Task.FromResult(true);
    }
}

Setting User Context (in Gateway/API)

// Before calling grains, set the user context
RequestContext.Set("UserContext", currentUserContext);
var grain = grainFactory.GetGrain<IUserGrain>(userId);
var user = await grain.GetUserAsync();

Authorization Flow

  1. Grain Call Initiated: Client calls a grain method
  2. Filter Evaluation: AuthorisationFilter checks if the grain interface matches configured prefixes
  3. Anonymous Check: Verifies if the method has [Anonymous] attribute
  4. User Context Validation: Ensures UserContext exists in RequestContext for protected methods
  5. Method Execution: Proceeds with grain method execution if authorized

Integration with Launchpad

This library integrates with other Nabs Launchpad components:

  • Core.Interfaces: Provides grain interfaces and shared contracts
  • Core.Context: Database context integration for grain persistence
  • Core.ServiceDefaults: Common service configuration and observability
  • Core.SiloClient: Client-side Orleans configuration for connecting to silos

Azure Configuration

The silo expects the following Azure services to be configured:

  • Azure Table Storage: For Orleans clustering (connection key: "clustering")
  • Azure Blob Storage: For grain state persistence (connection key: "grain-state")
  • SQL Server: For application data persistence

Monitoring

The Orleans Dashboard is automatically configured and available for monitoring:

  • Grain activation statistics
  • Cluster membership status
  • Performance metrics
  • Call tracing

Testing

The library includes comprehensive unit tests in the Launchpad.Core.Silo.UnitTests project. For integration testing, use the Nabs.Launchpad.Core.Testing.Silos library which provides test cluster capabilities.

Best Practices

  1. Grain Design: Follow Orleans best practices for grain state management
  2. Authorization: Use type prefixes to apply authorization selectively
  3. Anonymous Methods: Mark health checks and public APIs with [Anonymous]
  4. Error Handling: Implement proper error handling in grain methods
  5. Resource Management: Use proper disposal patterns for long-running operations

Contributing

This library follows the Nabs Launchpad coding standards:

  • Use C# 13 features and latest language constructs
  • Follow nullable reference types conventions
  • Implement proper async/await patterns
  • Include comprehensive unit tests

License

Copyright � Net Advantage Business Solutions

Product Compatible and additional computed target framework versions.
.NET 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.