Go Micro

Go Micro 是一个分布式系统开发框架。「Go Micro is a framework for distributed systems development」

Github stars Tracking Chart

Go Micro

Go Micro 是一个分布式系统开发框架。

概述

Go Micro 为分布式系统开发提供了核心需求,包括 RPC 和事件驱动通信。 Micro 的理念是合理的默认值和可插拔的架构。我们提供的默认值可以让您快速上手,但所有的东西都可以很容易地被替换掉。

特性

Go Micro 抽象出分布式系统的细节。以下是主要功能。

  • 认证 -- Auth 是作为一级公民内置的。认证和授权通过为每个服务提供身份和证书,实现安全的零信任网络。这还包括基于规则的访问控制。
  • 动态配置 -- 从任何地方加载和热重载动态配置。配置界面提供了一种从任何来源(如 env vars、文件等)加载应用级配置的方法。你可以合并这些来源,甚至可以定义回退。
  • 数据存储 -- 一个简单的数据存储接口,用于读取、写入和删除记录。它默认包括对内存、文件和 CockroachDB 的支持。状态和持久性成为原型设计之外的核心需求,Micro希望将其构建到框架中。
  • 服务发现 -- 自动服务注册和名称解析。服务发现是微服务开发的核心。当服务 A 需要和服务 B 对话时,需要该服务的位置。默认的发现机制是多播 DNS(mdns),是一个 zeroconf 系统。
  • 负载均衡 -- 建立在服务发现上的客户端负载均衡。一旦我们有了一个服务的任意数量实例的地址,我们现在需要一种方法来决定路由到哪个节点。我们使用随机散列负载均衡来提供服务间的均匀分布,如果有问题,我们会重试不同的节点。
  • 消息编码--基于内容类型的动态消息编码。客户端和服务器将使用编解码器与内容类型一起为您无缝编码和解码围棋类型。任何种类的消息都可以被编码并从不同的客户端发送。客户端和服务器默认会处理这些。这包括默认的 protobuf 和 json。
  • RPC 客户端/服务器 -- 基于 RPC 的请求/响应,支持双向流。我们提供了一个同步通信的抽象。向服务发出的请求将被自动解析、负载平衡、拨号和流式传输。
  • 异步消息传递 -- PubSub 是作为异步通信和事件驱动架构的一级公民而内置的。事件通知是微服务开发的核心模式。默认的消息系统是一个 HTTP 事件消息代理。
  • 同步化 -- 分布式系统通常以最终一致的方式构建。对分布式锁定和领导力的支持是作为 Sync 接口内置的。当使用最终一致的数据库或调度时,请使用同步接口。
  • 可插拔接口 -- Go Micro 为每个分布式系统抽象使用 Go 接口。正因为如此,这些接口是可插拔的,并允许 Go Micro 成为运行时不可知的。您可以插入任何底层技术。

入门

使用 Go Micro 的方法:

import "github.com/asim/go-micro/v3"

// create a new service
service := micro.NewService(
    micro.Name("helloworld"),
)

// initialise flags
service.Init()

// start the service
service.Run()

详细的使用方法请参见 示例

代码生成

参见 cmd/protoc-gen-micro 以了解 protobuf 代码的生成。

使用示例

请参见 examples 目录下的使用示例。

插件

所有插件请参见 plugins 目录。

许可证

Go Micro 已获得 Apache 2.0 许可。

社区

参见 SlackGitHub discussions

平台

Micro v3 将 Go Micro 整合到其中,成为一个统一的平台。请看 升级指南

(Second edition: vz revised at 2019.08.07)

(Third edition: vz revised at 2021.04.09)

Main metrics

Overview
Name With Ownermicro/go-micro
Primary LanguageGo
Program languageGo (Language Count: 2)
PlatformDocker, Kubernetes, Linux, Mac, Windows
License:Apache License 2.0
所有者活动
Created At2015-01-13 23:30:18
Pushed At2024-11-15 14:08:17
Last Commit At2024-11-15 15:08:17
Release Count378
Last Release Namev5.3.0 (Posted on 2024-07-08 18:50:00)
First Release Namev0.1.0 (Posted on 2017-06-12 12:50:51)
用户参与
Stargazers Count22k
Watchers Count510
Fork Count2.4k
Commits Count3.8k
Has Issues Enabled
Issues Count996
Issue Open Count10
Pull Requests Count1388
Pull Requests Open Count0
Pull Requests Close Count229
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Go Micro License GoDoc Travis CI Go Report Card

Go Micro is a framework for microservice development.

Overview

Go Micro provides the core requirements for distributed systems development including RPC and Event driven communication.
The micro philosophy is sane defaults with a pluggable architecture. We provide defaults to get you started quickly
but everything can be easily swapped out.

Plugins are available at github.com/micro/go-plugins.

Follow us on Twitter or join the Community.

Features

Go Micro abstracts away the details of distributed systems. Here are the main features.

  • Service Discovery - Automatic service registration and name resolution. Service discovery is at the core of micro service
    development. When service A needs to speak to service B it needs the location of that service. The default discovery mechanism is
    multicast DNS (mdns), a zeroconf system.

  • Load Balancing - Client side load balancing built on service discovery. Once we have the addresses of any number of instances
    of a service we now need a way to decide which node to route to. We use random hashed load balancing to provide even distribution
    across the services and retry a different node if there's a problem.

  • Message Encoding - Dynamic message encoding based on content-type. The client and server will use codecs along with content-type
    to seamlessly encode and decode Go types for you. Any variety of messages could be encoded and sent from different clients. The client
    and server handle this by default. This includes protobuf and json by default.

  • Request/Response - RPC based request/response with support for bidirectional streaming. We provide an abstraction for synchronous
    communication. A request made to a service will be automatically resolved, load balanced, dialled and streamed. The default
    transport is gRPC.

  • Async Messaging - PubSub is built in as a first class citizen for asynchronous communication and event driven architectures.
    Event notifications are a core pattern in micro service development. The default messaging system is an embedded NATS
    server.

  • Pluggable Interfaces - Go Micro makes use of Go interfaces for each distributed system abstraction. Because of this these interfaces
    are pluggable and allows Go Micro to be runtime agnostic. You can plugin any underlying technology. Find plugins in
    github.com/micro/go-plugins.

Getting Started

See the docs for detailed information on the architecture, installation and use of go-micro.