Skip to main content

API Reference

TNidus — application facade

TNidus is the single entry point for configuring and running a Nidus application. Obtain the singleton via GetNidus.

function GetNidus: TNidus;

Configuration methods (fluent, call before Start)

SignatureDescription
class function UseListener(const AListener: TListener): TNidusRegister a structured-log callback. Class method — call before GetNidus.
function UseGuard(const AGuardCallback: TGuardCallback): TNidusRegister a global authorization guard.
function UsePipes(const AValidationPipe: IValidationPipe): TNidusRegister the global validation pipe.
function UseCache(const ACache: IModuleCache): TNidusEnable module caching globally.
function UseCache(const ACache: IModuleCache; const AModules: array of TClass): TNidusEnable module caching for specific modules and apply policy.
function UsePools(const ARegistry: IPoolRegistry): TNidusSet a custom pool registry.
function UsePools<T: class, constructor>(const AMaxSize: Integer = 256): TNidusRegister a default object pool for T.
function UsePools<T: TComponent>(const AMaxSize: Integer = 32; const AOwner: TComponent = nil; const AReset: TProc<T> = nil): TNidusRegister a default component pool for T.
function UseComponentPool<T: TComponent>(const AMaxSize: Integer = 32; const AOwner: TComponent = nil; const AReset: TProc<T> = nil): TNidusAlias for UsePools<T: TComponent>.
function UseRPC(const ARPCProviderServer: IRPCProviderServer): TNidusSet the RPC transport server and start it.

Bootstrap

SignatureDescription
function Start(const AModule: TModule; const AInitialRoutePath: string = '/'): TNidusBoot the root module and start the route parser. Raises EModuleStartedException if called twice.
procedure FinalizeFree the module tree and tear down the DI container.

Runtime methods

SignatureDescription
function Get<T: class, constructor>(ATag: string = ''): TResolve a registered class by type (and optional tag).
function GetInterface<I: IInterface>(ATag: string = ''): IResolve a registered interface.
function LoadRouteModule(const APath: string; const AReq: IRouteRequest = nil): TReturnPairRun guard, validation pipe, and route dispatch for the given path.
procedure DisposeRouteModule(const APath: string)Walk path segments and dispose module instances for each segment.
procedure RegisterRouteHandler(const ARouteHandler: TRouteHandlerClass)Register a route handler class with the validation registry.
function PublishRPC(const ARPCName: string; const ARPCClass: TRPCResourceClass): TNidusPublish a named RPC handler. Raises ERPCProviderNotSetException if UseRPC was not called.
function Cache: IModuleCacheReturn the active IModuleCache instance.
function Pools: IPoolRegistryReturn the active IPoolRegistry instance.
function Request: IRouteRequestReturn the IRouteRequest for the current in-flight request.
procedure WithPool<T: class>(const AProc: TProc<T>)Acquire a pooled instance of T, run AProc, then release.
procedure WithPool<T: class>(const AKey: string; const AProc: TProc<T>)Named-key variant of WithPool.
procedure Listener(const AMessage: string)Emit a message through the registered listener.

IModuleCache

Defined in Nidus.Module.Cache.Interfaces.

MethodDescription
function ResolveInstance(const AModuleClass: TClass; const AFactory: TFunc<TObject>): TObjectReturn cached instance or call factory and cache the result.
procedure Invalidate(const AModuleClass: TClass)Evict cached instance for a specific module class.
procedure ClearEvict all cached instances (policy unchanged).
function SetPolicy(const AModuleClasses: array of TClass): IModuleCacheEnable caching for the listed classes (use TNidusCacheAll to cache all).
function EnableAll: IModuleCacheSet FCacheAll := True.
function DisableAll: IModuleCacheClear policy and evict all instances.
function IsEnabledFor(const AModuleClass: TClass): BooleanCheck whether a module is cached.

IPoolRegistry

Defined in Nidus.Pooling.Interfaces.

MethodDescription
procedure RegisterPool(const AKey: string; const APool: IPool)Register a pool instance under the given key.
function TryGetPool(const AKey: string; out APool: IPool): BooleanRetrieve a registered pool; returns False if not found.

The companion interface IPool (also in Nidus.Pooling.Interfaces) defines Acquire: TObject, procedure Release(const AValue: TObject), and function Count: Integer.

Global accessors: SetGlobalPoolRegistry(registry) and GetGlobalPoolRegistry.


TObjectPool<T>

Defined in Nidus.ObjectPool.

MethodDescription
function Acquire: TDequeue existing instance or call T.Create.
procedure Release(const AValue: T)Return instance to pool (frees if pool is full).
function Count: IntegerCurrent number of idle instances.

Constructor: Create(const AOptions: TObjectPoolOptions). TObjectPoolOptions.MaxSize (default 256) is the maximum idle capacity.


TMessageBus

Defined in Nidus.Message.Bus.

MethodDescription
procedure RegisterEvent<T>(const AName: string; const ACallback: TCallback<T>)Subscribe to a named topic.
procedure UnregisterEvent(const AName: string)Remove a subscription.
procedure Notify<T>(const AName: string; const AValue: T)Dispatch an event to matching subscribers (exact or wildcard prefix).

TRPCPublish

Defined in Nidus.RPC.Publish.

MethodDescription
procedure PublishRPC(const ARPCName: string; const ARPCClass: TRPCResourceClass)Register a name → class mapping.
procedure UnPublishRPC(const ARPCName: string)Remove a named RPC handler.
function RPCs: TDictionary<string, TRPCResourceClass>Return the full registry (read-only use).

TBind<T> — provider binding

Defined in Nidus.Bind.

Factory methodLifecycle
TBind<T>.Singleton(...)One instance, eager creation
TBind<T>.SingletonLazy(...)One instance, lazy creation
TBind<T>.Factory(...)New instance per resolution
TBind<T>.SingletonInterface<I>(...)Singleton registered under interface I
TBind<T>.AddInstance(AInstance)Use a pre-built instance

All factory methods accept optional AOnCreate: TProc<T>, AOnDestroy: TProc<T>, and AOnConstructorParams: TConstructorCallback callbacks.


Global functions

FunctionUnitDescription
GetNidus: TNidusNidusReturn the singleton TNidus instance from the DI container
SetGlobalModuleCache(ACache)Nidus.Module.Cache.InterfacesSet the global IModuleCache
GetGlobalModuleCache: IModuleCacheNidus.Module.Cache.InterfacesGet the global IModuleCache
SetGlobalPoolRegistry(ARegistry)Nidus.Pooling.InterfacesSet the global IPoolRegistry
GetGlobalPoolRegistry: IPoolRegistryNidus.Pooling.InterfacesGet the global IPoolRegistry
Nidus_Horse(AAppModule)Nidus.Driver.HorseBootstrap Nidus + return Horse middleware
Nidus_Horse(ACharset)Nidus.Driver.HorseReturn Horse middleware without bootstrapping