Skip to main content

@microde/microservice / MicroserviceModule

Abstract Class: MicroserviceModule

Defined in: microservice-module.ts:19

Defines the lifecycle shared by every module installed in a microservice.

Lifecycle methods run in phase order. Initialization and setup run in installation order, while teardown, shutdown, and cleanup run in reverse installation order. Each module declares its kind and can override the default no-op run and stop.

Constructors

Constructor

new MicroserviceModule(context): MicroserviceModule

Defined in: microservice-module.ts:27

Creates a module operating within the supplied microservice context.

Parameters

context

MicroserviceContext

Returns

MicroserviceModule

Properties

kind

abstract readonly kind: ModuleKind

Defined in: microservice-module.ts:20


providers

readonly providers: readonly Provider<unknown>[] = []

Defined in: microservice-module.ts:24

Owned contract values exported by this module instance.


relationships

readonly relationships: readonly RelationshipHandle[] = []

Defined in: microservice-module.ts:22

Relationship slots declared by this module instance.

Methods

cleanup()

cleanup(): Promise<void>

Defined in: microservice-module.ts:48

Performs final cleanup, including when an earlier lifecycle phase failed.

Returns

Promise<void>


initialize()

initialize(): Promise<void>

Defined in: microservice-module.ts:30

Acquires resources needed to configure the module.

Returns

Promise<void>


run()

run(_context): Promise<void>

Defined in: microservice-module.ts:36

Performs the module's work. Does nothing by default.

Parameters

_context

RunContext

Returns

Promise<void>


setup()

setup(_context): Promise<void>

Defined in: microservice-module.ts:33

Connects the initialized module to the rest of the service.

Parameters

_context

SetupContext

Returns

Promise<void>


shutdown()

shutdown(): Promise<void>

Defined in: microservice-module.ts:45

Releases resources acquired during initialization.

Returns

Promise<void>


stop()

stop(): Promise<void>

Defined in: microservice-module.ts:39

Requests that the module finish or release its running work. Does nothing by default.

Returns

Promise<void>


teardown()

teardown(): Promise<void>

Defined in: microservice-module.ts:42

Reverses work performed during setup.

Returns

Promise<void>