.NET API
TraconServiceCollectionExtensions
Tracon.Core.dllExtensions that register Tracon with dependency injection.
public static class TraconServiceCollectionExtensionsInheritance
Section titled “Inheritance”object ← TraconServiceCollectionExtensions
Inherited Members
Section titled “Inherited Members”object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Methods
Section titled “Methods”AddJobHandler<THandler>(IServiceCollection, string)
Section titled “ AddJobHandler<THandler>(IServiceCollection, string)”Adds an IJobHandler extension point under a handler key.
public static IServiceCollection AddJobHandler<THandler>(this IServiceCollection services, string handlerKey) where THandler : class, IJobHandlerParameters
Section titled “Parameters”services IServiceCollection
Service collection.
handlerKey string
The key jobs are dispatched by. 1-128 characters: lowercase ASCII
letters, digits, ., _, or -, starting with a
letter or digit. Pick a namespace prefix of your own
(contoso.nightly-report).
Returns
Section titled “Returns”The same collection, for chaining.
Type Parameters
Section titled “Type Parameters”THandler
The handler type to add.
Remarks
Section titled “Remarks”The worker dispatches by exact, ordinal key match, so
this call may appear before or after AddTracon
— registration order does not decide which handler runs, and no handler
can shadow another.
The handler is registered scoped and resolved from a
fresh scope for every execution, so it may take scoped dependencies in
its constructor. Registering two handlers under the same key, or using
a key inside Tracon’s own tracon. namespace, stops the
host from starting.
builder.Services.AddJobHandler<NightlyReportJobHandler>("contoso.nightly-report");Exceptions
Section titled “Exceptions”services is null.
handlerKey is empty, malformed, or inside the
JobHandlerKeys.ReservedPrefix namespace.
AddTracon(IHostApplicationBuilder)
Section titled “ AddTracon(IHostApplicationBuilder)”Adds Tracon to the host application builder and reads settings from
the Tracon section.
public static ITraconBuilder AddTracon(this IHostApplicationBuilder builder)Parameters
Section titled “Parameters”builder IHostApplicationBuilder
The host application builder.
Returns
Section titled “Returns”The configuration chain.
Remarks
Section titled “Remarks”The one call every Tracon application starts with. On its own it runs with in-memory stores and needs no database; a provider and a store are added to the chain it returns.
var builder = WebApplication.CreateBuilder(args);
builder.AddTracon() .UseOpenAI(builder.Configuration["OpenAI:ApiKey"]!) .UsePostgreSql(builder.Configuration.GetConnectionString("Tracon")!);Exceptions
Section titled “Exceptions”builder is null.
AddTracon(IServiceCollection, IConfiguration?)
Section titled “ AddTracon(IServiceCollection, IConfiguration?)”Adds Tracon to the service collection.
public static ITraconBuilder AddTracon(this IServiceCollection services, IConfiguration? configurationSection = null)Parameters
Section titled “Parameters”services IServiceCollection
Service collection.
configurationSection IConfiguration?
Configuration section settings are read from.
Returns
Section titled “Returns”The configuration chain.
Remarks
Section titled “Remarks”All services are registered with TryAdd. If you register your own
implementation before this call, yours wins; Tracon does not overwrite it.
When no additional configuration is done, Tracon runs with in-memory stores and requires no database.
Exceptions
Section titled “Exceptions”services is null.
UseScheduling(IServiceCollection, Action<TraconSchedulingOptions>?)
Section titled “ UseScheduling(IServiceCollection, Action<TraconSchedulingOptions>?)”Sets batch and scheduled run settings from code.
public static IServiceCollection UseScheduling(this IServiceCollection services, Action<TraconSchedulingOptions>? configure = null)Parameters
Section titled “Parameters”services IServiceCollection
Service collection.
configure Action<TraconSchedulingOptions>?
Settings modifier. When not given, only the defaults/configuration apply.
Returns
Section titled “Returns”The same collection, for chaining.
Remarks
Section titled “Remarks”The job queue and scheduling stores are already registered by
AddTracon; this method only changes the settings (e.g.
turning off this process’s background worker with
o.RunWorker = false). PostConfigure is used, so the value
given from code always wins over the value coming from the configuration file.
// A web instance that serves requests and leaves the jobs to a worker process.builder.Services.UseScheduling(o => o.RunWorker = false);Exceptions
Section titled “Exceptions”services is null.