mirror of
https://github.com/go-micro/go-micro.git
synced 2026-04-30 19:15:24 +02:00
c800dd3729
Docker Compose deployment example (examples/deployment/): - docker-compose.yml with Consul, MCP gateway, Jaeger tracing - Dockerfile and Dockerfile.gateway for multi-stage builds - README with architecture diagram and customization guide Cross-service workflow example (examples/mcp/workflow/): - Inventory, Orders, Notifications services - Shows agents orchestrating multi-step workflows from natural language - Stock check → reserve → order → notify in a single agent conversation MCP gateway benchmark suite (gateway/mcp/benchmark_test.go): - ListTools: ~20μs (10 tools), ~48μs (100 tools) - Tool lookup: ~19ns (zero-alloc, scales to 500+ tools) - Auth inspect: ~7ns, scope check: ~16ns - Rate limiter: ~111ns per check - JSON encode/decode: ~1.5-2μs per tool Updated examples README with new examples index. https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc Co-authored-by: Claude <noreply@anthropic.com>
2.3 KiB
2.3 KiB
Go Micro Examples
This directory contains runnable examples demonstrating various go-micro features and patterns.
Quick Start
Each example can be run with go run . from its directory.
Examples
hello-world
Basic RPC service demonstrating core concepts:
- Service creation and registration
- Handler implementation
- Client calls
- Health checks
Run it:
cd hello-world
go run .
web-service
HTTP web service with service discovery:
- HTTP handlers
- Service registration
- Health checks
- JSON REST API
Run it:
cd web-service
go run .
multi-service
Multiple services in a single binary — the modular monolith pattern:
- Isolated server, client, store, and cache per service
- Shared registry and broker for inter-service communication
- Coordinated lifecycle with
service.Group - Start monolith, split later when you need to scale independently
Run it:
cd multi-service
go run .
deployment
Docker Compose deployment with MCP gateway, Consul registry, and Jaeger tracing:
- Production-like architecture in one
docker-compose up - Standalone MCP gateway connected to service registry
- Distributed tracing with OpenTelemetry + Jaeger
MCP Examples
See the mcp/ directory for AI agent integration examples:
- hello - Minimal MCP service (start here)
- crud - CRUD contact book with full agent documentation
- workflow - Cross-service orchestration via AI agents
- documented - All MCP features with auth scopes
agent-demo
Multi-service project management app (Projects, Tasks, Team) with seed data and agent playground integration.
Coming Soon
- pubsub-events - Event-driven architecture with NATS
- grpc-integration - Using go-micro with gRPC
Prerequisites
Some examples require external dependencies:
- NATS:
docker run -p 4222:4222 nats:latest - Consul:
docker run -p 8500:8500 consul:latest agent -dev -ui -client=0.0.0.0 - Redis:
docker run -p 6379:6379 redis:latest
Contributing
To add a new example:
- Create a new directory
- Add a descriptive README.md
- Include working code with comments
- Add to this index
- Ensure it runs with
go run .