service-registry
npx machina-cli add skill athola/claude-night-market/service-registry --openclawTable of Contents
- Overview
- When to Use
- Core Concepts
- Service Configuration
- Execution Result
- Quick Start
- Register Services
- Execute via Service
- Health Checks
- Service Selection
- Auto-Selection
- Failover Pattern
- Integration Pattern
- Detailed Resources
- Exit Criteria
Service Registry
Overview
A registry pattern for managing connections to external services. Handles configuration, health checking, and execution across multiple service integrations.
When To Use
- Managing multiple external services.
- Need consistent execution interface.
- Want health monitoring across services.
- Building service failover logic.
When NOT To Use
- Single service integration without registry needs
Core Concepts
Service Configuration
@dataclass
class ServiceConfig:
name: str
command: str
auth_method: str # "api_key", "oauth", "token"
auth_env_var: str
quota_limits: dict
models: list[str] = field(default_factory=list)
Verification: Run the command with --help flag to verify availability.
Execution Result
@dataclass
class ExecutionResult:
success: bool
stdout: str
stderr: str
exit_code: int
duration: float
tokens_used: int
Verification: Run the command with --help flag to verify availability.
Quick Start
Register Services
from leyline.service_registry import ServiceRegistry
registry = ServiceRegistry()
registry.register("gemini", ServiceConfig(
name="gemini",
command="gemini",
auth_method="api_key",
auth_env_var="GEMINI_API_KEY",
quota_limits={"rpm": 60, "daily": 1000}
))
Verification: Run the command with --help flag to verify availability.
Execute via Service
result = registry.execute(
service="gemini",
prompt="Analyze this code",
files=["src/main.py"],
model="gemini-2.5-pro"
)
if result.success:
print(result.stdout)
Verification: Run the command with --help flag to verify availability.
Health Checks
# Check single service
status = registry.health_check("gemini")
# Check all services
all_status = registry.health_check_all()
for service, healthy in all_status.items():
print(f"{service}: {'OK' if healthy else 'FAILED'}")
Verification: Run the command with --help flag to verify availability.
Service Selection
Auto-Selection
# Select best service for task
service = registry.select_service(
requirements={
"large_context": True,
"fast_response": False
}
)
Verification: Run the command with --help flag to verify availability.
Failover Pattern
def execute_with_failover(prompt: str, files: list) -> ExecutionResult:
for service in registry.get_healthy_services():
result = registry.execute(service, prompt, files)
if result.success:
return result
raise AllServicesFailedError()
Verification: Run the command with --help flag to verify availability.
Integration Pattern
# In your skill's frontmatter
dependencies: [leyline:service-registry]
Verification: Run the command with --help flag to verify availability.
Detailed Resources
- Service Config: See
modules/service-config.mdfor configuration options. - Execution Patterns: See
modules/execution-patterns.mdfor advanced usage.
Exit Criteria
- Services registered with configuration.
- Health checks passing.
- Execution results properly handled.
Troubleshooting
Common Issues
Command not found Ensure all dependencies are installed and in PATH
Permission errors Check file permissions and run with appropriate privileges
Unexpected behavior
Enable verbose logging with --verbose flag
Source
git clone https://github.com/athola/claude-night-market/blob/master/plugins/leyline/skills/service-registry/SKILL.mdView on GitHub Overview
A registry pattern for managing connections to multiple external services. It centralizes service configuration, health monitoring, and unified execution, enabling consistent interfaces and robust failover across integrations.
How This Skill Works
Define a ServiceConfig for each external service, including name, command, auth_method, quota_limits, and optional models. The ServiceRegistry stores these configurations, exposes execute, health_check, and select_service, and delegates actual work to the service-executor.
When to Use It
- Managing and coordinating calls to multiple external services with a single interface
- Needing a consistent execution pattern across different service integrations
- Implementing health monitoring and status checks for all services
- Building failover and automatic service selection to improve reliability
- Centralizing configuration management for services and quotas
Quick Start
- Step 1: Register services with ServiceRegistry, specifying name, command, auth_method, and quotas
- Step 2: Execute tasks via registry.execute(service, ...), and inspect result.stdout or result.stderr
- Step 3: Run registry.health_check and registry.health_check_all to validate availability and monitor health
Best Practices
- Define clear quotas and auth_method per service
- Keep service configs versionable and include models if needed
- Leverage health_check and health_check_all for proactive monitoring
- Use unified-execution patterns to ensure consistent results
- Test failover scenarios and auto-selection in staging
Example Use Cases
- Orchestrating API calls to payment, identity, and analytics services via a single registry
- Enforcing per-service quotas and rate limits across a multi-service backend
- Health-check enabled routing to healthy services only
- Automatic failover between competing providers for high availability
- Centralized configuration for service endpoints in a microservices platform
Frequently Asked Questions
Related Skills
terraform
chaterm/terminal-skills
Terraform 基础设施即代码
makefile-generation
athola/claude-night-market
Generate language-specific Makefiles with testing, linting, and automation targets. Use for project initialization and workflow standardization. Skip if Makefile exists.
precommit-setup
athola/claude-night-market
Configure three-layer pre-commit system with linting, type checking, and testing hooks. Use for quality gate setup and code standards. Skip if pre-commit is optimally configured.
error-patterns
athola/claude-night-market
'Standardized error handling patterns with classification, recovery,
risk-classification
athola/claude-night-market
'Inline risk classification for agent tasks using a 4-tier model. Hybrid
quota-management
athola/claude-night-market
'Quota tracking, threshold monitoring, and graceful degradation for rate-limited