Skip to content

Configuration ​

GrydReports configuration is split into:

  • GrydReportsOptions (main module behavior)
  • GrydFiles:Profiles:gryd.report (where generated files are stored — see File Storage)
  • ReportDeliveryOptions (delivery defaults)
  • ReportScheduleOptions (recurring scheduling guardrails)

Use the facade for the standard stack (Application + Infrastructure + API):

csharp
builder.Services.AddGrydReports(
    builder.Configuration,
    db => db.UseNpgsql(builder.Configuration.GetConnectionString("GrydReports"))
);

This automatically binds GrydReportsOptions from GrydReports section in appsettings.json.

Advanced Setup (Fine-Grained) ​

Use Infrastructure registration directly when you need explicit option callbacks:

csharp
builder.Services.AddGrydReportsApplication();
builder.Services.AddGrydReportsInfrastructure(
    configureOptions: options =>
    {
        options.RetentionDays = 90;
        options.EnableAutoCleanup = true;

        options.MaxSyncGenerationSize = 50 * 1024 * 1024; // 50 MB
        options.SyncGenerationTimeout = TimeSpan.FromMinutes(2);
        options.ForceAsyncAboveBytes = 10 * 1024 * 1024; // 10 MB

        options.AutoRegisterTemplates = true;
        options.TemplateAssemblies.Add(typeof(Program).Assembly);

        options.Caching.Enabled = true;
        options.Caching.DefaultExpiration = TimeSpan.FromHours(1);
        options.Caching.TemplateExpirations["daily-sales"] = TimeSpan.FromMinutes(30);

        options.DigitalSignature = new DigitalSignatureOptions
        {
            Enabled = true,
            CertificatePath = "/certs/report-signing.pfx",
            CertificatePassword = "secure-password",
            Reason = "Official Document",
            Location = "Sao Paulo, BR"
        };
    },
    configureDbContext: db =>
        db.UseNpgsql(builder.Configuration.GetConnectionString("GrydReports"))
);
builder.Services.AddGrydReportsApi();

appsettings.json ​

GrydReports section is bound to GrydReportsOptions. ConnectionStrings:Jobs is only needed when you enable recurring scheduling with GrydJobs.

json
{
  "ConnectionStrings": {
    "GrydReports": "Host=localhost;Database=gryd_reports;Username=postgres;Password=postgres",
    "Jobs": "Host=localhost;Port=5432;Database=gryd_jobs;Username=postgres;Password=postgres"
  },
  "GrydReports": {
    "RetentionDays": 90,
    "EnableAutoCleanup": true,
    "MaxSyncGenerationSize": 52428800,
    "SyncGenerationTimeout": "00:02:00",
    "ForceAsyncAboveBytes": 10485760,
    "AutoRegisterTemplates": true,
    "Caching": {
      "Enabled": false,
      "DefaultExpiration": "01:00:00",
      "TemplateExpirations": {
        "daily-sales": "00:30:00"
      }
    },
    "DigitalSignature": {
      "Enabled": false,
      "CertificatePath": "",
      "CertificatePassword": "",
      "Reason": "Official Document",
      "Location": ""
    }
  },
  "GrydFiles": {
    "Profiles": {
      "gryd.report": {
        "MaxSizeBytes": 52428800,
        "AllowedContentTypes": [
          "application/pdf",
          "text/csv",
          "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        ],
        "ScanRequired": false,
        "DefaultRetentionMode": "UntilReleased"
      }
    }
  }
}

File Storage (GrydFiles) ​

Generated reports are stored in GrydFiles, the platform's file module, in process. There is no report-specific storage configuration: the bucket is the one GrydStorage configures, and the rules come from the gryd.report profile. The host registers the file module; GrydReports refuses to start when the gryd.report profile is not declared.

csharp
builder.Services.AddGrydObjectStorage(builder.Configuration);
builder.Services.AddGrydFiles(builder.Configuration);
builder.Services.AddGrydFilesClamAv(builder.Configuration);
builder.Services.AddGrydReports(builder.Configuration, db => db.UseNpgsql(connectionString));
gryd.report settingMeaning for reports
AllowedContentTypesMust include the type of every format you render: application/pdf, text/csv, the XLSX type. A report of a format the profile does not accept fails to store
MaxSizeBytesThe largest report that can be stored
ScanRequired: falseThe antivirus is waived — the file never left this process. The server still computes the SHA-256 and checks the content against the type, and the waiver is written to the audit trail at start-up
DefaultRetentionMode: UntilReleasedThe file lives while its execution holds it. Deleting the execution releases it, and GrydFiles purges it after GrydFiles:PurgeGracePeriodDays
DownloadUrlTtlMinutesHow long a download URL from GET /reports/{id}/download stays valid (default 5)

Each stored report is referenced by its execution with owner scope gryd.report-execution and owner key equal to the execution id. See the GrydFiles pages on retention and purge and download.

Delivery Configuration ​

Configure default delivery constraints and message templates:

csharp
builder.Services.ConfigureGrydReportsDelivery(opts =>
{
    opts.DefaultSenderEmail = "reports@company.com";
    opts.DefaultSenderName = "Report System";
    opts.DefaultEmailSubject = "Report: {ReportName} - {Date}";
    opts.DefaultEmailBody = "Please find the attached report.";
    opts.MaxRecipients = 50;
    opts.WebhookTimeout = TimeSpan.FromSeconds(30);
    opts.RetryCount = 3;
});

Scheduling Configuration (Optional) ​

Recurring scheduling is optional and only applies when:

  • GrydReports.Scheduling.GrydJobs package is installed
  • builder.Services.AddGrydReportsScheduling() is registered
csharp
builder.Services.ConfigureGrydReportsScheduling(opts =>
{
    // 0 = unlimited schedules per tenant
    opts.MaxSchedulesPerTenant = 0;

    opts.MaxConsecutiveFailures = 3;
    opts.MinimumInterval = TimeSpan.FromHours(1);
    opts.NotifyOnAutoPause = true;
});

Per-Template Permissions ​

Configure RBAC per template through GrydReportsOptions:

csharp
builder.Services.Configure<GrydReportsOptions>(opts =>
{
    opts.Permissions["financial-report"] = new ReportPermissions
    {
        Generate = ["admin", "finance-manager"],
        View = ["admin", "finance-manager", "finance-analyst"],
        Download = ["admin", "finance-manager"],
        Schedule = ["admin"]
    };

    opts.Permissions["inventory-report"] = new ReportPermissions
    {
        Generate = ["admin", "warehouse-manager"],
        View = ["admin", "warehouse-manager", "warehouse-staff"],
        Download = ["admin", "warehouse-manager"],
        Schedule = ["admin", "warehouse-manager"]
    };
});

Global Reports ​

Mark templates that do not require tenant scope filtering:

csharp
builder.Services.Configure<GrydReportsOptions>(opts =>
{
    opts.GlobalReports.Add(typeof(SystemHealthTemplate));
    opts.GlobalReports.Add(typeof(PlatformUsageTemplate));
});

Health Checks ​

Register module health checks:

csharp
builder.Services.AddGrydReportsHealthChecks(builder.Configuration);

This registers:

  • grydreports-database: PostgreSQL connectivity
  • grydreports-self: module self-check

Map endpoint:

csharp
app.MapHealthChecks("/health", new HealthCheckOptions
{
    Predicate = check => check.Tags.Contains("grydreports")
});

Option Reference ​

GrydReportsOptions ​

OptionTypeDefaultDescription
ConnectionStringstring?nullReport metadata connection string
RetentionDaysint90Days to keep generated reports
EnableAutoCleanupbooltrueEnables automatic retention cleanup
MaxSyncGenerationSizelong50 MBMax file size for sync generation
SyncGenerationTimeoutTimeSpan2 minTimeout for sync generation
ForceAsyncAboveByteslong?nullForces async generation above threshold
AutoRegisterTemplatesbooltrueAuto-discovers report templates
Caching.EnabledboolfalseEnables output caching
Caching.DefaultExpirationTimeSpan1 hourDefault cache TTL
DigitalSignature.EnabledboolfalseEnables PDF digital signing

ReportDeliveryOptions ​

OptionTypeDefaultDescription
DefaultSenderEmailstring?nullDefault sender email
DefaultSenderNamestring?nullDefault sender display name
DefaultEmailSubjectstringReport: {ReportName} - {Date}Subject template
DefaultEmailBodystringPlease find the attached report.Body template
MaxRecipientsint50Max email recipients
WebhookTimeoutTimeSpan30sWebhook timeout
RetryCountint3Delivery retry attempts

ReportScheduleOptions (optional scheduling) ​

OptionTypeDefaultDescription
MaxSchedulesPerTenantint0Max active schedules per tenant (0 = unlimited)
MaxConsecutiveFailuresint3Auto-pause threshold
MinimumIntervalTimeSpan1 hourMinimum allowed schedule interval
NotifyOnAutoPausebooltrueNotify when schedule auto-pauses

Released under the MIT License.