Service Invocation (sdk.services)

Call other functions or services within your project using RPC (Remote Procedure Call).

Introduction

import { AerostackServer } from '@aerostack/sdk';
 
const sdk = new AerostackServer(env);
const result = await sdk.services.invoke('billing-service', { ...payload });

Features

invoke(serviceName, data, options)

Call a registered service by name. This uses high-speed internal communication.

  • serviceName: The unique name of the service/worker.
  • data: JSON payload.
  • options.timeout: Request timeout in ms (default 30s).
try {
  const invoice = await sdk.services.invoke('billing', {
    action: 'create-invoice',
    userId: '123'
  });
  console.log(invoice.id);
} catch (error) {
  // Handle service errors (timeout, not found)
}

This feature requires [[dispatch_namespaces]] or Service Bindings configured in aerostack.toml.