RpcModule class abstract

Shared lifecycle base for all framework modules.

Subclass RpcServerModule to expose RPC services, or RpcClientModule to connect to remote services. Use RpcModule directly only for infrastructure modules that register shared DI bindings without contracts (e.g. a database pool module depended on by other modules).

Startup order

Declare dependencies to guarantee ordering. If module B declares List<Type> get dependencies => [A], the framework starts A before B and stops B before A. Circular dependencies throw StateError.

Example — infrastructure module

class DatabaseModule extends RpcModule {
  @override
  String get name => 'DatabaseModule';

  @override
  void configureWithEnv(RpcContainer c, RpcEnvConfig env) {
    c.registerSingleton<DbPool>(DbPool(env.require('DATABASE_URL')));
  }

  @override
  Future<RpcHealthStatus?> checkHealth() async {
    final ok = await _pool.ping();
    return ok
      ? RpcHealthStatus.healthy(component: name, message: 'db ok')
      : RpcHealthStatus.unhealthy(component: name, message: 'db unreachable');
  }
}
Implementers

Constructors

RpcModule()

Properties

dependencies List<Type>
Module types that must be configured and started before this module.
no setter
hashCode int
The hash code for this object.
no setterinherited
name String
Human-readable module name used in logs and health reports.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

checkHealth() Future<RpcHealthStatus?>
Returns a health status for this module, or null to skip health reporting.
configure(RpcContainer container) → void
Register services into container.
configureWithEnv(RpcContainer container, RpcEnvConfig env) → void
Register environment-dependent services into container.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onStart(RpcContainer container) Future<void>
Called after the transport has started and all modules are configured.
onStop() Future<void>
Called before the transport is shut down.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited