allenxuxu / microservices Goto Github PK
View Code? Open in Web Editor NEWmicro 微服务实例教程,包含JWT鉴权、熔断、监控、链路追踪、健康检查、跨域等
Home Page: https://note.mogutou.xyz/category/go-micro
micro 微服务实例教程,包含JWT鉴权、熔断、监控、链路追踪、健康检查、跨域等
Home Page: https://note.mogutou.xyz/category/go-micro
首先,感谢例子,受益良多。
调用Inject时候,应该使用sp.Tracer().Inject,否则在jaeger中链路无法串起来。
go build -o ../build/microGW main.go
go: github.com/micro/[email protected] requires
k8s.io/[email protected] requires
github.com/gogo/[email protected]: invalid pseudo-version: revision is shorter than canonical (65acae22fc9d)
这个错误,我该如何解决?谢谢
window 怎么跑
背景: 想实现在三台服务器主机完成微服务分布式部署
目标: 其中任意一台服务器宕机不影响整个业务使用
准备工作: 在三台服务器上完成consul 集群部署
现在server1上 , 运行 micro api , hello-srv, hello-api 工作正常 , http://192.168.0.1:8080/hello 接口访问成功
然后我尝试在server2 上重复server1操作 ,同样指定 --registry=consul --registry_address=192.168.0.1:8500,
但是发现访问http://192.168.0.1:8080/hello, server1中 micro api log 会出现:
2020-04-01 03:44:47.493251 I | hystrix breaker err: hystrix: timeout
2020-04-01 03:44:47.493531 I | http: proxy error: context canceled
2020-04-01 03:44:47.493547 I | status code 502
而且server2中的也没有接受到请求
所以现在有几个问题想请教一下:
rpcx这个框架有服务自理,也支持类似插件化的功能,性能也比grpc好,求指教
consul服务器不在本地主机userSRV无法启动一起报错
protoc --proto_path=/Users/allen/dev/go/src:. --micro_out=. --go_out=. proto/user/user.proto
go build -o ../../build/userSRV main.go
../../build/userSRV --registry=consul --registry_address=192.168.31.30:8500
2019/05/20 15:27:43 error loading source consul: Get http://127.0.0.1:8500/v1/kv/micro/config/?recurse=: dial tcp 127.0.0.1:8500: connect: connection refused
make: *** [run] Error 1
Go micro 微服务实战 QQ群184572648
你好, 我clone代码后加了几个接口,都可以运行起来, 测试发现, 长时间不访问后调用接口, 偶然会出现502错误, 还没有解决, google 也没找到有用的信息, 来请教一下
`
192.168.0.1 - - [03/Mar/2020:01:45:06 +0000] "GET /metrics HTTP/1.1" 200 1479 "" "Prometheus/2.16.0"
2020-03-03 01:45:21.403572 I | auth plugin received: /metrics
2020-03-03 01:45:21.404120 I | GET-/metrics
192.168.0.1 - - [03/Mar/2020:01:45:21 +0000] "GET /metrics HTTP/1.1" 200 1478 "" "Prometheus/2.16.0"
2020-03-03 01:45:26.622715 I | auth plugin received: /device/activate
2020-03-03 01:45:26.623343 I | POST-/device/activate
2020-03-03 01:45:27.652417 I | hystrix breaker err: hystrix: timeout
210.22.74.67 - - [03/Mar/2020:01:45:26 +0000] "POST /device/activate HTTP/1.1" 200 0 "" ""
2020-03-03 01:45:27.654895 I | http: proxy error: context canceled
2020-03-03 01:45:27.665910 I | http: superfluous response.WriteHeader call from github.com/gorilla/handlers.(*responseLogger).WriteHeader (handlers.go:65)
2020-03-03 01:45:27.666027 I | status code 502
2020-03-03 01:45:36.403598 I | auth plugin received: /metrics
2020-03-03 01:45:36.404147 I | GET-/metrics
192.168.0.1 - - [03/Mar/2020:01:45:36 +0000] "GET /metrics HTTP/1.1" 200 1482 "" "Prometheus/2.16.0"
`
访问api模块: http://localhost:8081/user/test
{
message: "Hi, this is the Greeter API"
}
但是访问gateway 405
request url : http://localhost:8080/user/test
{
id: "go.micro.client.transport",
code: 500,
detail: "405 Not Allowed: <html> <head><title>405 Not Allowed</title></head> <body bgcolor="white"> <center><h1>405 Not Allowed</h1></center> <hr><center>nginx/1.8.1</center> </body> </html> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> ",
status: "Internal Server Error"
}
auth和broker注释掉也报这个错误,请问gateway如何访问其他微服务模块的呢? 谢谢。
部署在云服务器上会panic: WriteHeader called after Handler finished
micro Api panic 必现步骤 :
1. 先把熔断阀值调高
hystrix.DefaultMaxConcurrent = 100000
hystrix.DefaultVolumeThreshold = 100000
2. 熔断超时调低
hystrix.DefaultTimeout = 100
3 .用压测工具 webbench 高并发请求接口必panic "panic: net/http: CloseNotify called after ServeHTTP finished"
在这之前想请教下 Demo里面 user-api里超时设置 hystrix.DefaultTimeout = 5000 , 但是我在breaker/hystrix.go打印依然是默认的1000, 在api/user/main.go设置是不是没有生效? 所以上述的步骤里面几句代码是加在了, breaker/hystrix.go init()函数里面
Hi @Allenxuxu, nice to meet you! I'm learning with your code, thanks for share!
Can you help me with the issue below?
$ make run
go build -o ../../build/userAPI main.go
../../build/userAPI --registry=consul
2019/05/03 21:32:48 error loading source consul: source not found: /micro/config/
make: *** [run] Error 1
感谢你写的go-micro例子,关于micro api想请教一下啊:1,micro api 你把auth trace breaker 等中间件全部让api网关执行,会影响性能么?2,micro api 感觉是所有请求的入口,如果网关后端对应着几十个服务,所有的请求都走网关,会不会成为性能瓶颈啊,对网关可以做负载均衡吗?还有如何防单点故障呢?对于api网关我一直困惑这几点。谢谢。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.