Go Micro

repository·master·Indexed 12 days ago

https://github.com/micro/go-micro

A framework for building distributed microservices and intelligent AI agents. It features a pluggable architecture for service discovery, RPC, pub/sub, and persistent storage, with first-class support for LLM integration, agentic workflows, and cross-framework communication (A2A/MCP). Includes a CLI for service scaffolding, management, and a production API gateway with JWT-based authentication and scope-based access control.

Tokens
229K
Snippets
737
Records
1K
Agent score
97%

What's inside Go Micro

  1. Overview of the Config package

    master
    The config package provides a pluggable, dynamic configuration management system for Go applications. It allows you to load, merge, and observe configuration from multiple sources (such as environment variables, flags, files, etcd, or Kubernetes ConfigMaps) into a single, unified in-memory view. It is designed to handle complex loading logic and background updates automatically.
  2. What is Go Micro?

    master

    Go Micro is an agent harness and service framework for Go. It provides a runtime environment (harness) for agents, including tools, memory, guardrails, workflows, state, discovery, and interop.

    Key capabilities:

    • Agent Harness: Provides models, memory, tools, planning, delegation, and service discovery.
    • AI-Callable Tools: Every service endpoint can be turned into an AI-callable tool via MCP and A2A.
    • Orchestration: Use durable flows to orchestrate deterministic parts of your system.
    • Pluggable Architecture: Built on Go interfaces for service discovery, client/server RPC, pub/sub, auth, caching, and storage, allowing you to swap any component with sane defaults provided out of the box.
  3. Current and Upcoming Agent Harness Features

    master

    The Go Micro agent harness provides several capabilities for operating agent loops.

    Currently Shipped Features:

    • Tools-from-services: Automatic tool discovery from existing services.
    • Store-backed memory: Persistent state for agents.
    • Guardrails: Safety controls for execution.
    • Durable flows: Includes 'run-until-done' loops.
    • Plan/Delegate: Built-in mechanisms for task decomposition.
    • Interop: Support for MCP, A2A, and x402.

    Roadmap (In Development):

    • Resilience: Propagation of deadlines, timeouts, and retry/backoff logic through the entire loop.
    • Durable agent runs: Ability to checkpoint and resume agent runs after a restart (similar to durable flows).
    • Observability: Full visibility into runs via OpenTelemetry spans, inspectable via the CLI.
    • Streaming: End-to-end token streaming through chat, agent RPC, and A2A.
  4. Core features of the Go Micro distributed system substrate

    master

    Go Micro provides several built-in primitives for building distributed systems:

    • Service Discovery: Automatic registration and name resolution. The default is mdns (multicast DNS).
    • RPC Client/Server: Synchronous request/response with support for bidirectional streaming. Requests are automatically resolved, load balanced, and dialed.
    • Load Balancing: Client-side load balancing using random hashed distribution and automatic retries.
    • Authentication & Authorization: Built-in identity and certificates for zero-trust networking, including rule-based access control.
    • Dynamic Config: A pluggable interface to load and hot-reload configuration from sources like environment variables, files, or etcd.
    • Data Storage: A simple interface for CRUD operations on records, supporting various backends via plugins.
    • Async Messaging (PubSub): An event-driven architecture for asynchronous communication. The default broker is an HTTP event message broker.
    • Message Encoding: Dynamic encoding/decoding based on content-type (e.g., protobuf and json are supported by default).
    • Pluggable Interfaces: All core abstractions (registry, broker, store, transport, codecs, auth, and config) are Go interfaces, making the runtime agnostic to the underlying technology.
  5. Features of the Micro server

    master

    The Micro server provides several capabilities for managing and interacting with your microservices:

    • Web Dashboard: Browse registered services, view endpoints, and inspect request/response schemas.
    • API Gateway: Acts as an authenticated HTTP-to-RPC proxy at the path /api/{service}/{method}.
    • JWT Authentication: All API endpoints require a Bearer token or a session cookie.
    • Token Management: Tools to generate, view, copy, and revoke JWT tokens.
    • User Management: Create, list, and delete users (passwords are bcrypt-hashed).
    • Endpoint Scopes: Use /auth/scopes to restrict which tokens can call specific endpoints.
    • MCP Integration: Includes an AI agent playground and MCP tools with scope enforcement.
    • Logs & Status: Monitor service logs and status (including PID and uptime) directly from the dashboard.
  6. Use the API Gateway to translate HTTP to RPC

    master

    The gateway/api package provides an HTTP API gateway that translates incoming HTTP requests into RPC calls for your microservices. It also includes a web dashboard for browsing and testing services.

    Key features include:

    • HTTP to RPC translation: Call microservices via standard HTTP.
    • Web dashboard: Browse and test services in a browser.
    • Authentication: Optional JWT-based authentication.
    • MCP integration: Expose services to AI agents (note: MCP must be run as a separate server).
    • Service discovery: Automatically detects services from the registry.
  7. Compare Go Micro with other frameworks

    master

    Go Micro is a 'batteries included' microservices framework for Go, designed for low boilerplate and rapid development. It contrasts with other tools as follows:

    FeatureGo Microgo-kitgRPCDapr
    Learning CurveLowHighMediumMedium
    BoilerplateLowHighMediumLow
    Plugin SystemBuilt-inExternalLimitedSidecar
    Service DiscoveryYes (mDNS, Consul, etc)No (BYO)NoYes
    Load BalancingClient-sideNoNoSidecar
    Pub/SubYesNoNoYes
    TransportHTTP, gRPC, NATSBYOgRPC onlyHTTP, gRPC
    Zero-config DevYes (mDNS)NoNoNo (needs sidecar)
    Production ReadyYesYesYesYes
    LanguageGo onlyGo onlyMulti-languageMulti-language
  8. What is Go Micro and how is it used?

    master

    Go Micro is an agent harness and service framework for Go. It provides the runtime environment necessary for an agent to operate a system rather than just responding to prompts.

    Key components of the harness include:

    • Tools & Memory: The capabilities and state an agent uses.
    • Guardrails & Workflows: Safety mechanisms and structured execution paths.
    • Discovery & Protocols: How agents find and communicate with services.
    • State & Checkpoint/Resume: Managing long-running agentic processes.
    • Gateways: Support for MCP (Model Context Protocol) and A2A (Agent-to-Agent) communication, including streaming, push notifications, and multi-turn continuation.

    Building an agent with Go Micro is conceptually equivalent to building a distributed service that can discover, call, and recover from failures in other services.

  9. Durable Agent vs. Durable Flow: When to use each

    master

    Choosing between a durable flow and a checkpointed agent run depends on whether the execution path is predefined or dynamic:

    • Durable Flow: Use when the path is known ahead of time (e.g., ordered service calls, retries, timers, compensation, or specific resume stages like reserve or charge).
    • Checkpointed Agent Run: Use when the path is open-ended and the model chooses tools dynamically, but you must ensure completed tool side effects are not replayed after a crash.

    Composition: These patterns can be composed. You can maintain deterministic business processes in a flow-durable and hand off judgment-heavy, model-directed steps to a checkpointed agent. Both use the same Checkpoint backend, allowing inspection and recovery to share a single run-history store.