Skip to content

Commit 76bfeae

Browse files
asimclaude
andauthored
Claude/update docs roadmap f zd2 j (#2880)
* docs: update all four documentation guides and mark Q2 complete - ai-native-services: add WithMCP one-liner, standalone gateway, WebSocket client example, and OpenTelemetry observability section - mcp-security: add OTel distributed tracing, WebSocket authentication (connection-level and per-message), DeniedReason audit field - tool-descriptions: add manual overrides with WithEndpointDocs and export formats section - agent-patterns: add LangChain/LlamaIndex SDK pattern and standalone gateway production pattern with Docker example - Update roadmap: mark Q2 documentation as complete, Q2 at 100% - Update status: reflect all recent completions, shift priorities https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * feat: add agent demo example and blog post Add examples/agent-demo with a multi-service project management app (projects, tasks, team) that demonstrates AI agents interacting with Go Micro services through MCP. Includes seed data and example prompts. Add blog post 4 "Agents Meet Microservices: A Hands-On Demo" walking through the example code and showing cross-service agent workflows. https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * feat: enable multiple services in a single binary Remove global state mutations from service and cmd option functions so that configuring one service no longer overwrites another's settings. Key changes: - service/options.go: remove all DefaultXxx global writes from option functions; newOptions() now creates fresh Server, Client, Store, and Cache per service while sharing Registry, Broker, and Transport - cmd/cmd.go: newCmd() uses local copies instead of pointers to package globals; Before() no longer mutates DefaultXxx vars - cmd/options.go: remove global mutations from all option functions - service/service.go: export ServiceImpl type for cross-package use - service/group.go: new Group type for multi-service lifecycle - micro.go: add Start/Stop to Service interface, expose Group and NewGroup convenience function - examples/multi-service: working example with two services https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * docs: highlight multi-service binary support Add multi-service section to README with code example, update features list, add to examples index, and note in status summary. https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * feat: unify service API and clean up developer experience - Unified service creation: micro.New("name", opts...) as canonical API - Clean handler registration: service.Handle(handler, opts...) accepts server.HandlerOption args directly, no need to reach through Server() - Unexported serviceImpl: users interact through Service interface only - Service groups use Service interface (not concrete type) - Fixed Stop() to properly propagate BeforeStop/AfterStop errors - Fixed store init: error-level log instead of fatal on init failure - Updated all examples to use consistent patterns - Updated README, getting-started, MCP docs, and guides - Added blog post about the DX cleanup https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * fix: add blog post 5 to blog index Blog post 5 (Developer Experience Cleanup) existed as a file but was missing from the blog index page. https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * feat: make micro new generate MCP-enabled services by default - main.go template includes mcp.WithMCP(":3001") by default - Handler template has agent-friendly doc comments with @example tags - Proto template has descriptive field comments - README includes MCP usage, Claude Code config, and tool description tips - Makefile adds mcp-tools, mcp-test, mcp-serve targets - go.mod updated to Go 1.22 - Added --no-mcp flag to opt out of MCP integration - Post-create output shows MCP endpoint URLs https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * docs: add MCP migration guide and troubleshooting guide - Migration guide: 3 approaches to add MCP to existing services (WithMCP one-liner, standalone gateway, CLI) - Troubleshooting guide: common issues with agents, WebSocket, Claude Code, auth, rate limiting, and performance https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * refactor: rename model/ package to ai/ for AI model providers The model/ package name conflicted with the conventional use of "model" for data models. Renamed to ai/ which better describes the package's purpose (AI provider abstraction for Anthropic, OpenAI, etc.) and frees up model/ for future data model layer use. - Rename model/ → ai/ with package name change - Update all Go imports from go-micro.dev/v5/model to go-micro.dev/v5/ai - Update cmd/micro/server/server.go references (model.X → ai.X) - Update all documentation and roadmap references - All tests pass, CLI builds successfully https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * feat: add model package for typed data access with CRUD and queries New model/ package provides a typed data model layer using Go generics. Supports structured CRUD operations, WHERE filters, ordering, pagination, and automatic schema creation from struct tags. Three backends: - memory: in-memory for development and testing - sqlite: embedded SQL for dev and single-node production - postgres: full PostgreSQL for production deployments Key features: - Generic Model[T] with Create/Read/Update/Delete/List/Count - Query builder: Where(), WhereOp(), OrderAsc/Desc(), Limit(), Offset() - Struct tags: model:"key" for primary key, model:"index" for indexes - Auto table creation from struct schema - 19 tests passing across memory and sqlite backends https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * feat: add model code generation to protoc-gen-micro Extend the micro plugin to generate model structs from proto messages annotated with // @model. Generated alongside client/server code in the same .pb.micro.go file. For a proto message like: // @model message User { string id = 1; string name = 2; } Generates: - UserModel struct with model:"key" and json tags - NewUserModel(db) factory returning *model.Model[UserModel] - UserModelFromProto(*User) *UserModel converter - (*UserModel).ToProto() *User converter Supports @model(table=custom_table, key=custom_field) options. Adds GetComments() to generator for plugin comment inspection. https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * feat: add Model() to Service interface for Client/Server/Model trifecta Every service now exposes Client(), Server(), and Model() — call services, handle requests, and save/query data from the same interface. Includes README docs, blog post, and a full model guide on the docs site. https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f07a49e commit 76bfeae

39 files changed

Lines changed: 3506 additions & 490 deletions

CLAUDE.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ make test
1414

1515
# Run tests for a specific package
1616
go test ./gateway/mcp/...
17+
go test ./ai/...
1718
go test ./model/...
1819

1920
# Lint
@@ -48,9 +49,13 @@ go-micro/
4849
├── health/ # Health checking
4950
├── logger/ # Logging
5051
├── metadata/ # Context metadata
51-
├── model/ # AI model providers
52+
├── ai/ # AI model providers
5253
│ ├── anthropic/ # Claude provider
5354
│ └── openai/ # GPT provider
55+
├── model/ # Typed data models (CRUD, queries, schemas)
56+
│ ├── memory/ # In-memory backend (dev/testing)
57+
│ ├── sqlite/ # SQLite backend (dev/single-node)
58+
│ └── postgres/ # PostgreSQL backend (production)
5459
├── registry/ # Service discovery (mDNS, Consul, etcd)
5560
├── selector/ # Client-side load balancing
5661
├── server/ # RPC server
@@ -118,7 +123,8 @@ Build compelling demos showing agents interacting with go-micro services in real
118123
|---------|------|
119124
| MCP Gateway | `gateway/mcp/mcp.go` |
120125
| MCP Docs | `gateway/mcp/DOCUMENTATION.md` |
121-
| Model Interface | `model/model.go` |
126+
| AI Interface | `ai/model.go` |
127+
| Model Layer | `model/model.go` |
122128
| CLI Entry | `cmd/micro/main.go` |
123129
| MCP CLI | `cmd/micro/mcp/` |
124130
| Server (run/server) | `cmd/micro/server/server.go` |

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ Go Micro abstracts away the details of distributed systems. Here are the main fe
2424
- **Data Storage** - A simple data store interface to read, write and delete records. It includes support for many storage backends
2525
in the plugins repo. State and persistence becomes a core requirement beyond prototyping and Micro looks to build that into the framework.
2626

27+
- **Data Model** - A typed data model layer with CRUD operations, queries, and multiple backends (memory, SQLite, Postgres). Define Go
28+
structs with tags and get type-safe Create/Read/Update/Delete/List/Count operations. Accessible via `service.Model()` alongside
29+
`service.Client()` and `service.Server()` for a complete service experience: call services, handle requests, save and query data.
30+
2731
- **Service Discovery** - Automatic service registration and name resolution. Service discovery is at the core of micro service
2832
development. When service A needs to speak to service B it needs the location of that service. The default discovery mechanism is
2933
multicast DNS (mdns), a zeroconf system.
@@ -165,6 +169,74 @@ Each service gets its own server, client, store, and cache while sharing the reg
165169

166170
See the [multi-service example](examples/multi-service/) for a working demo.
167171

172+
## Data Model
173+
174+
Go Micro includes a typed data model layer for persistence. Define a struct, tag a key field, and get type-safe CRUD and query operations backed by memory, SQLite, or Postgres.
175+
176+
```go
177+
import (
178+
"go-micro.dev/v5/model"
179+
"go-micro.dev/v5/model/sqlite"
180+
)
181+
182+
// Define your data type
183+
type User struct {
184+
ID string `json:"id" model:"key"`
185+
Name string `json:"name"`
186+
Email string `json:"email" model:"index"`
187+
Age int `json:"age"`
188+
}
189+
```
190+
191+
Create a model from the service's database and use it:
192+
193+
```go
194+
service := micro.New("users")
195+
196+
// Create a typed model using the service's database
197+
users := model.New[User](service.Model())
198+
199+
// CRUD operations
200+
users.Create(ctx, &User{ID: "1", Name: "Alice", Email: "alice@example.com", Age: 30})
201+
202+
user, _ := users.Read(ctx, "1")
203+
204+
user.Name = "Alice Smith"
205+
users.Update(ctx, user)
206+
207+
users.Delete(ctx, "1")
208+
```
209+
210+
Query with filters, ordering, and pagination:
211+
212+
```go
213+
// Find users by field
214+
results, _ := users.List(ctx, model.Where("email", "alice@example.com"))
215+
216+
// Complex queries
217+
results, _ = users.List(ctx,
218+
model.WhereOp("age", ">=", 18),
219+
model.OrderDesc("name"),
220+
model.Limit(10),
221+
model.Offset(20),
222+
)
223+
224+
count, _ := users.Count(ctx, model.Where("age", 30))
225+
```
226+
227+
Swap backends with an option:
228+
229+
```go
230+
// Development: in-memory (default)
231+
service := micro.New("users")
232+
233+
// Production: SQLite or Postgres
234+
db, _ := sqlite.New(model.WithDSN("file:app.db"))
235+
service := micro.New("users", micro.Model(db))
236+
```
237+
238+
Every service gets `Client()`, `Server()`, and `Model()` — call services, handle requests, and save data all from the same interface.
239+
168240
## Examples
169241

170242
Check out [/examples](examples/) for runnable code:
@@ -296,6 +368,7 @@ Package reference: https://pkg.go.dev/go-micro.dev/v5
296368

297369
**User Guides:**
298370
- [Getting Started](internal/website/docs/getting-started.md)
371+
- [Data Model](internal/website/docs/model.md)
299372
- [MCP & AI Agents](internal/website/docs/mcp.md)
300373
- [Plugins Overview](internal/website/docs/plugins.md)
301374
- [Learn by Example](internal/website/docs/examples/index.md)

ROADMAP.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ This roadmap outlines the planned features and improvements for Go Micro. Commun
1717
- [ ] Plugin discovery dashboard
1818

1919
### AI & Model Integration
20-
- [x] Model package with provider abstraction (`model.Model` interface)
21-
- [x] Anthropic Claude provider (`model/anthropic`)
22-
- [x] OpenAI GPT provider (`model/openai`)
20+
- [x] AI package with provider abstraction (`ai.Model` interface)
21+
- [x] Anthropic Claude provider (`ai/anthropic`)
22+
- [x] OpenAI GPT provider (`ai/openai`)
2323
- [x] Tool execution with auto-calling support
24-
- [x] Streaming support via `model.Stream`
24+
- [x] Streaming support via `ai.Stream`
2525

2626
### Observability
2727
- [ ] OpenTelemetry native support

0 commit comments

Comments
 (0)