Archetypical.Software.Vega.Api.Abstractions
1.5.0
See the version list below for details.
dotnet add package Archetypical.Software.Vega.Api.Abstractions --version 1.5.0
NuGet\Install-Package Archetypical.Software.Vega.Api.Abstractions -Version 1.5.0
<PackageReference Include="Archetypical.Software.Vega.Api.Abstractions" Version="1.5.0" />
<PackageVersion Include="Archetypical.Software.Vega.Api.Abstractions" Version="1.5.0" />
<PackageReference Include="Archetypical.Software.Vega.Api.Abstractions" />
paket add Archetypical.Software.Vega.Api.Abstractions --version 1.5.0
#r "nuget: Archetypical.Software.Vega.Api.Abstractions, 1.5.0"
#addin nuget:?package=Archetypical.Software.Vega.Api.Abstractions&version=1.5.0
#tool nuget:?package=Archetypical.Software.Vega.Api.Abstractions&version=1.5.0
Archetypical.Software.Vega.Api.Abstractions
Base controllers and other service registry helpers.
Getting Started
Instructions to get started with this project.
Usage
VegaApiOptions
The VegaApiOptions
class allows you to configure various aspects of the Vega API. Here are the main properties:
ServiceName
: The name of the service.Version
: The version of the API.TurnOff
: Options to disable certain features.OpenTelemetryOptions
: Options for OpenTelemetry configuration.DistributedCache
: Options for configuring the Dapr distributed cache (DaprDistributedCacheOptions
). Default state store name is "statestore".
BuilderExtensions
The BuilderExtensions
class provides methods to configure and initialize the Vega API. Key methods include:
CreateVegaApi
: Sets up the API with the provided options. This includes configuring controllers, OData, OpenTelemetry, Dapr integration, and registering theDaprDistributedCache
as the defaultIDistributedCache
implementation if Dapr is enabled.ConfigureDbContext
: Configures the database context.ConfigureOtel
: Configures OpenTelemetry for logging, tracing, and metrics.ExposeOData
: Exposes OData endpoints.UseVegaApiDefaults
: Applies default configurations and initializes contexts.
appsettings.json
The appsettings.json
file is used to configure the application settings, including logging levels, allowed hosts, and Vega-specific settings such as database connection strings and API version.
Example configuration:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"VEGA": {
"DBCONTEXT": {
"CONNECTIONSTRING": "Data Source=test.db;",
"PROVIDER": "SQLite"
},
"API": {
"VERSION": "1.0-pre1",
"OpenTelemetryOptions": {
"Tracing": {
"EntityFramework": {
"LogStatement": false
}
}
},
"DistributedCache": {
"StateStoreName": "my-cache-store" // Replace with your Dapr state store component name
}
}
}
}
Dapr Distributed Cache
This library includes an IDistributedCache
implementation, DaprDistributedCache
, that leverages a configured Dapr state store component.
Configuration
When Dapr is enabled (via VegaApiOptions.TurnOff.Dapr = false
), the CreateVegaApi
extension method automatically registers DaprDistributedCache
as the singleton implementation for IDistributedCache
.
The specific Dapr state store component to use can be configured via appsettings.json
or environment variables.
appsettings.json
Configuration
You can specify the Dapr state store component name within the VEGA
configuration section:
{
"VEGA": {
// ... other VEGA settings
"API": {
// ... other API settings
"DistributedCache": {
"StateStoreName": "my-cache-store" // Replace with your Dapr state store component name
}
}
}
}
If not specified, it defaults to using a Dapr state store named "statestore"
.
Dependencies
- Requires the
Dapr.AspNetCore
package. - Requires a running Dapr sidecar with a configured state store component matching the
StateStoreName
.
VegaDbContext
The VegaDbContext
class is the base class for all Vega DbContexts. It uses default environment variables for the connection string and database provider, and supports both in-memory and SQLite for testing. All other DbContexts should inherit from this class.
Parameters
options
: The options to be used by a DbContext.configuration
: The configuration to be used for retrieving environment variables.logger
: The logger to be used for logging information, warnings, and errors.
Exceptions
ArgumentNullException
: Thrown when the configuration is null.InvalidOperationException
: Thrown when the configuration section 'VEGA:DBCONTEXT' is missing.
Remarks
The class supports multiple database providers:
- MSSQL: Uses Microsoft SQL Server as the database provider.
- SQLITE: Uses SQLite as the database provider.
- COCKROACHDB: Uses CockroachDB as the database provider.
- POSTGRESQL: Uses PostgreSQL as the database provider.
- InMemory: Uses an in-memory database for testing purposes when no provider is specified.
Configuring Database Providers
The VegaDbContext
class supports multiple database providers. You can configure the desired provider and connection string in the appsettings.json
file under the VEGA:DBCONTEXT
section.
Supported Database Providers
- Microsoft SQL Server (MSSQL)
- SQLite
- CockroachDB
- PostgreSQL
- InMemory (for testing purposes)
Configuration Examples
Microsoft SQL Server (MSSQL)
{
"VEGA": {
"DBCONTEXT": {
"CONNECTIONSTRING": "Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;",
"PROVIDER": "MSSQL"
}
}
}
SQLite
{
"VEGA": {
"DBCONTEXT": {
"CONNECTIONSTRING": "Data Source=mydatabase.db;",
"PROVIDER": "SQLite"
}
}
}
CockroachDB
{
"VEGA": {
"DBCONTEXT": {
"CONNECTIONSTRING": "Host=myHost;Port=26257;Database=myDatabase;Username=myUsername;Password=myPassword;",
"PROVIDER": "COCKROACHDB"
}
}
}
PostgreSQL
{
"VEGA": {
"DBCONTEXT": {
"CONNECTIONSTRING": "Host=myHost;Port=5432;Database=myDatabase;Username=myUsername;Password=myPassword;",
"PROVIDER": "POSTGRESQL"
}
}
}
InMemory (for testing purposes)
{
"VEGA": {
"DBCONTEXT": {
"PROVIDER": "InMemory"
}
}
}
Environment Variables
You can also configure the database connection using environment variables. The environment variables should start with VEGA__DBCONTEXT__
followed by the property name in uppercase.
Example for PostgreSQL:
export VEGA__DBCONTEXT__PROVIDER=POSTGRESQL
export VEGA__DBCONTEXT__PGHOST=myHost
export VEGA__DBCONTEXT__PGPORT=5432
export VEGA__DBCONTEXT__PGDATABASE=myDatabase
export VEGA__DBCONTEXT__PGUSER=myUsername
export VEGA__DBCONTEXT__PGPASSWORD=myPassword
These configurations will be picked up by the VegaDbContext
class during initialization.
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. |
-
net8.0
- AspNetCore.HealthChecks.ApplicationStatus (>= 9.0.0)
- AspNetCore.HealthChecks.Dapr (>= 9.0.0)
- Dapr.AspNetCore (>= 1.15.2)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 8.0.13)
- Microsoft.AspNetCore.OData (>= 9.2.1)
- Microsoft.EntityFrameworkCore (>= 9.0.3)
- Microsoft.EntityFrameworkCore.InMemory (>= 9.0.3)
- Microsoft.EntityFrameworkCore.Sqlite (>= 9.0.3)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.3)
- Microsoft.Extensions.Caching.Memory (>= 9.0.3)
- Microsoft.Extensions.Diagnostics.Probes (>= 9.0.0-preview.9.24556.5)
- Microsoft.Extensions.Diagnostics.ResourceMonitoring (>= 9.3.0)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 9.0.4)
- OpenTelemetry.Exporter.Console (>= 1.11.2)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.11.2)
- OpenTelemetry.Extensions.Hosting (>= 1.11.2)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.11.1)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.0.0-beta.12)
- OpenTelemetry.Instrumentation.Http (>= 1.11.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.11.1)
- Swashbuckle.AspNetCore (>= 8.1.0)
- Swashbuckle.AspNetCore.ReDoc (>= 8.1.0)
- Swashbuckle.AspNetCore.SwaggerGen (>= 8.1.0)
- System.Diagnostics.DiagnosticSource (>= 9.0.3)
-
net9.0
- AspNetCore.HealthChecks.ApplicationStatus (>= 9.0.0)
- AspNetCore.HealthChecks.Dapr (>= 9.0.0)
- Dapr.AspNetCore (>= 1.15.2)
- Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 9.0.3)
- Microsoft.AspNetCore.OData (>= 9.2.1)
- Microsoft.EntityFrameworkCore (>= 9.0.3)
- Microsoft.EntityFrameworkCore.InMemory (>= 9.0.3)
- Microsoft.EntityFrameworkCore.Sqlite (>= 9.0.3)
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.3)
- Microsoft.Extensions.Caching.Memory (>= 9.0.3)
- Microsoft.Extensions.Diagnostics.Probes (>= 9.0.0-preview.9.24556.5)
- Microsoft.Extensions.Diagnostics.ResourceMonitoring (>= 9.3.0)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 9.0.4)
- OpenTelemetry.Exporter.Console (>= 1.11.2)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.11.2)
- OpenTelemetry.Extensions.Hosting (>= 1.11.2)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.11.1)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.0.0-beta.12)
- OpenTelemetry.Instrumentation.Http (>= 1.11.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.11.1)
- Swashbuckle.AspNetCore (>= 8.1.0)
- Swashbuckle.AspNetCore.ReDoc (>= 8.1.0)
- Swashbuckle.AspNetCore.SwaggerGen (>= 8.1.0)
- System.Diagnostics.DiagnosticSource (>= 9.0.3)
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.3 | 151 | 4/12/2025 |
2.0.2 | 67 | 4/11/2025 |
2.0.1 | 161 | 4/10/2025 |
2.0.0 | 160 | 4/9/2025 |
1.5.0 | 144 | 4/7/2025 |
1.4.0 | 144 | 4/2/2025 |
1.3.0 | 117 | 4/1/2025 |
1.2.8 | 128 | 3/31/2025 |
1.2.7 | 128 | 3/31/2025 |
1.2.6 | 98 | 3/27/2025 |
1.2.5 | 106 | 3/27/2025 |
1.2.4 | 97 | 3/27/2025 |
1.2.3 | 442 | 3/26/2025 |
1.2.2 | 159 | 3/11/2025 |
1.2.1 | 215 | 3/6/2025 |
1.2.0 | 238 | 3/3/2025 |
1.1.0 | 168 | 2/23/2025 |
1.0.6 | 73 | 2/23/2025 |
1.0.5 | 199 | 12/11/2024 |
1.0.4 | 76 | 12/9/2024 |