Skip to content

ServiceBuilder

Defined in: packages/hoppity/src/ServiceBuilder.ts:79

The contract-driven service builder.

Built by hoppity.service(), supports .use(middleware) chaining and .build() to produce a wired ServiceBroker.

Build phases when .build() is called:

  1. Derive topology from handlers + publishes
  2. Merge with optional raw topology (raw is base, derived layers on top)
  3. Run middleware pipeline (they see the complete topology)
  4. Create Rascal broker via BrokerAsPromised.create()
  5. Wire event/command/rpc handlers (subscribe to queues, wrap with interceptors)
  6. Wire outbound methods (publishEvent, sendCommand, request, cancelRequest — wrap with interceptors)
  7. Run middleware onBrokerCreated callbacks (they see the fully-wired broker)

new ServiceBuilder(serviceName, config): ServiceBuilder

Defined in: packages/hoppity/src/ServiceBuilder.ts:90

string

ServiceConfig

ServiceBuilder

build(): Promise<ServiceBroker>

Defined in: packages/hoppity/src/ServiceBuilder.ts:116

Builds the service broker by executing all phases in order.

Promise<ServiceBroker>


use(middleware): ServiceBuilder

Defined in: packages/hoppity/src/ServiceBuilder.ts:108

Adds middleware to the pipeline.

MiddlewareFunction

ServiceBuilder