Path: redb-route/redb.Route/Core/ComponentBase.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route/Core/ComponentBase.cs
----
using Microsoft.Extensions.Logging;
using redb.Route.Abstractions;
namespace redb.Route.Core;
///
/// Base class for components. Provides scheme registration and endpoint creation contract.
/// Components MAY hold long-lived resources (connection pools, broker sessions);
/// override to release them when shuts down.
///
public abstract class ComponentBase : IComponent, IAsyncDisposable
{
///
public abstract string Scheme { get; }
///
public virtual IReadOnlyList AlternateSchemes => [];
///
/// Route context that owns this component. Set automatically by .
/// Used by transport endpoints to resolve named connection factories from the registry.
///
public IRouteContext? Context { get; internal set; }
///
/// Logger for the component. Set automatically by
/// from the context's .
///
public ILogger? Logger { get; internal set; }
///
public abstract IEndpoint CreateEndpoint(EndpointUri uri);
///
/// Optional one-line path synonym for the structured XML form:
/// kafka → topic, rabbitmq → queue, file → directory. Read by the XML
/// loader, the component catalog and the generated schema — never from a hand-kept list.
/// A component without an override is addressed by the universal path attribute.
///
public virtual string? StructuredPathSynonym => null;
///
/// The path part of this component's URIs is a text body (sql: the query). The structured
/// XML form then reads the path from the element's content (CDATA) rather than an attribute.
///
public virtual bool PathIsText => false;
///
/// Releases component-owned long-lived resources. Default implementation is a no-op.
/// Override in subclasses that hold connection pools, broker sessions, etc.
/// Called by .
///
public virtual ValueTask DisposeAsync() => ValueTask.CompletedTask;
}