All Projects → Allenxuxu → Microservices

Allenxuxu / Microservices

micro 微服务实例教程,包含JWT鉴权、熔断、监控、链路追踪、健康检查、跨域等

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Microservices

Micro Starter Kit
Cloud Native GoLang Microservices - gRPC, GraphQL
Stars: ✭ 167 (-51.03%)
Mutual labels:  microservices, go-micro, micro
Micro
go-micro 微服务实践,更多请关注Micro中国站☞
Stars: ✭ 383 (+12.32%)
Mutual labels:  microservices, go-micro, micro
Remit
RabbitMQ-backed microservices supporting RPC, pubsub, automatic service discovery and scaling with no code changes.
Stars: ✭ 24 (-92.96%)
Mutual labels:  microservices, micro
Go Microservices
Examples of microservices written in Go using different frameworks
Stars: ✭ 113 (-66.86%)
Mutual labels:  microservices, go-micro
Go Micro Boilerplate
The boilerplate of the GoLang application with a clear microservices architecture.
Stars: ✭ 147 (-56.89%)
Mutual labels:  microservices, go-micro
Micro Open Graph
A tiny Node.js microservice to scrape open graph data with joy.
Stars: ✭ 371 (+8.8%)
Mutual labels:  microservices, micro
Micro Github
A tiny microservice that makes adding authentication with GitHub to your application easy.
Stars: ✭ 726 (+112.9%)
Mutual labels:  microservices, micro
Micro
Micro is a distributed cloud operating system
Stars: ✭ 10,778 (+3060.7%)
Mutual labels:  microservices, micro
Xconf
分布式配置中心
Stars: ✭ 185 (-45.75%)
Mutual labels:  microservices, micro
micro-starter
Micro 微服务实践
Stars: ✭ 391 (+14.66%)
Mutual labels:  micro, go-micro
micro-plugins
go-micro plugins, auth(JWT+Casbin)、go-micro服务加入istio服务网格
Stars: ✭ 27 (-92.08%)
Mutual labels:  micro, go-micro
Wl Micro Frontends
Micro front end practical project tutorial. 微前端项目实战vue项目。基于vue3.0&qiankun2.0进阶版:https://github.com/wl-ui/wl-mfe
Stars: ✭ 366 (+7.33%)
Mutual labels:  microservices, micro
Go Os
Stars: ✭ 185 (-45.75%)
Mutual labels:  go-micro, micro
Go Grpc
A simpler grpc framework
Stars: ✭ 133 (-61%)
Mutual labels:  go-micro, micro
Protoc Gen Micro
Protobuf code generation for Micro. Moved to go-micro/cmd/protoc-gen-micro.
Stars: ✭ 270 (-20.82%)
Mutual labels:  go-micro, micro
Go Plugins
Go Micro Plugins. Moved to go-micro/plugins.
Stars: ✭ 1,654 (+385.04%)
Mutual labels:  go-micro, micro
Gomicro note
go-micro学习笔记
Stars: ✭ 62 (-81.82%)
Mutual labels:  go-micro, micro
S
a go web freamwork for micro service, very very easy to create and deploy, with auto service registry and discover, high performance and based on http/2 no ssl
Stars: ✭ 67 (-80.35%)
Mutual labels:  go-micro, micro
Event Sourcing Microservices Example
Learn about building microservices with event sourcing using Spring Boot and how to deploy a social network to Kubernetes using Docker Compose or Helm.
Stars: ✭ 167 (-51.03%)
Mutual labels:  microservices, tutorial
protoc-gen-micro
Protobuf code generation
Stars: ✭ 287 (-15.84%)
Mutual labels:  micro, go-micro

microservices

使用micro微服务框架的一些例子,包含微服务开发中必备的鉴权,熔断,监控,链路追踪,跨域等

主要内容

  • 扩展micro的API网关功能
    • 跨域
    • JWT鉴权
    • 熔断
    • prometheus监控
    • 链路追踪
  • gin开发微服务service
    • 熔断
    • prometheus监控
    • 链路追踪
  • 内部服务采用grpc通信
  • 服务健康检查

实现详解

各部分实现,都在博客中有相应博文讲解 个人博客

跨域配置

要实现跨域,只需要在 micro api(micro API 网关)注册相关插件,并且通过命令行指定跨域相关信息即可。

plugin.Register(cors.NewPlugin())
micro api 
--cors-allowed-headers=X-Custom-Header,X-Header 
--cors-allowed-origins=someotherdomain.com,xx.com 
--cors-allowed-methods=POST

本项目使用consul的K/V存储来模拟一个配置中心。在每一个使用到lib/token包的服务都会在main函数里传递consul地址和JWT私钥的加载路径。在srv/user服务中同样,使用consul K/V 来存储mysql数据库的配置。在启动服务之前,需要现在consul的K/V中设置好这些配置。

image image

使用到的其他软件

  • consul (服务发现,K/V配置)
  • prometheus (监控)
  • jaeger (链路追踪)
  • hystrix-dashboard (hystrix熔断仪表盘)
  • mysql

prometheus 参考配置文件

global:
  scrape_interval: 15s
  scrape_timeout: 10s
  evaluation_interval: 15s
alerting:
  alertmanagers:
  - static_configs:
    - targets: []
    scheme: http
    timeout: 10s
scrape_configs:
- job_name: APIGW
  honor_timestamps: true
  scrape_interval: 15s
  scrape_timeout: 10s
  metrics_path: /metrics
  scheme: http
  static_configs:
  - targets:
    - 10.104.34.106:8080   #10.104.34.106为本机ip, 本机127.0.0.1在容器中无法访问到

docker启动参考命令

  • consul

    docker run --name consul -d -p 8500:8500/tcp consul agent -server -ui -bootstrap-expect=1 -client=0.0.0.0

  • prometheus (启动时依赖本机配置文件 /tmp/conf.yml , 可更改命令自定义路径)

    docker run --name prometheus -d -p 0.0.0.0:9090:9090 -v /tmp/conf.yml:/etc/prometheus/prometheus.yml prom/prometheus

  • jaeger

    docker run -d --name jaeger
    -e COLLECTOR_ZIPKIN_HTTP_PORT=9411
    -p 5775:5775/udp
    -p 6831:6831/udp
    -p 6832:6832/udp
    -p 5778:5778
    -p 16686:16686
    -p 14268:14268
    -p 9411:9411
    jaegertracing/all-in-one:1.6

  • hystrix-dashboard

    docker run --name hystrix-dashboard -d -p 8081:9002 mlabouardy/hystrix-dashboard:latest

    hystrix数据监控 http://localhost:8081/hystrix.stream

  • mysql

    docker run --name mysql -e MYSQL_ROOT_PASSWORD=123 -d -p 3306:3306 mysql

快速体验

image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].