Execution
services
Service deployment and management for microservices architecture
services
Deploy and manage microservices with automatic service discovery, load balancing, and health monitoring.
Overview
The services primitive enables you to deploy and orchestrate microservices with built-in service mesh capabilities, making it easy to build distributed systems.
SDK Object Mapping
This primitive maps to RPC communication via the api SDK object (one of 8 core):
import { api, service, on, send } from 'sdk.do'
// Define service with RPC endpoints
const userService = service('user-service', {
endpoints: {
getUser: async ({ userId }) => await db.get('users', userId),
createUser: async ({ user }) => await db.create('users', user),
updateUser: async ({ userId, updates }) => await db.update('users', userId, updates),
},
})
// API - Call service via RPC (api is one of 8 core SDK objects)
const user = await api.service('user-service').getUser({ userId: '123' })
// Service mesh communication
await api.service('order-service').createOrder({
userId: user.id,
items: ['item-1', 'item-2'],
})
// ON - Service events (on is one of 8 core SDK objects)
on($.Service.called, async ({ service, method, params }) => {
await send($.Analytics.track, {
event: 'service.method_called',
service: service.name,
method,
duration: performance.now(),
})
})Subdomain Architecture
The services primitive uses infinite free subdomains for service deployment:
services.do # Root - Service orchestration
├── {service-name}.services.do # Individual service endpoints
└── {custom}.services.do # Custom service deploymentsChild Primitives
- business-as-code - Business process modeling
- services-as-software - AI-powered service delivery
Quick Example
import { service } from 'sdk.do'
const userService = service('user-service', {
endpoints: {
getUser: async ({ userId }) => await db.get('users', userId),
createUser: async ({ user }) => await db.create('users', user),
},
})
const user = await userService.getUser({ userId: '123' })Core Capabilities
- Service Discovery - Automatic registration and discovery
- Load Balancing - Distribute traffic across instances
- Health Monitoring - Automatic health checks
- Circuit Breaking - Prevent cascading failures
- Version Management - Deploy multiple versions
Access Methods
SDK
TypeScript/JavaScript library for service definition
const user = await service('user-service').getUser({ userId: '123' })CLI
Command-line tool for service deployment
do service deploy user-service --endpoints ./endpoints/ --instances 3API
REST/RPC endpoints for service management
curl -X POST https://api.do/v1/services/user-service/call/getUser -d '{"userId":"123"}'MCP
Model Context Protocol for AI assistant integration
Call method "getUser" on service "user-service" with userId "123"Related Primitives
Child Primitives
- business-as-code - Business process modeling
- services-as-software - AI-powered service delivery