Code Monkey home page Code Monkey logo

go-chassis's Introduction

Coverage Status Go Report Card GoDoc HitCount
goproxy.cn Documentation Status

中文版README

Go-Chassis is a microservice framework for rapid development of microservices in Go. it focus on helping developer to deliver cloud native application more easily. The idea of logo is, developer can recreate and customize their own "wheel"(a framework) by go chassis to accelerate the delivery of software.

Why use Go chassis

  • powerful middleware "handler chain": powerful than "filter" or "interceptor". each handler in chain is able to get the running result of backward handler and your business logic. It is very useful in varies of scenario, for example:
  1. a circuit breaker need to check command results
  2. track response status and record it, so that prometheus can collect them
  3. track critical response result, so that you can audit them
  4. distribute tracing, you can complete the end span spec after business logic executed

the commonplace above is helping you decouple common function from business logic. without handler chain. those function will couple with business logic

  • go chassis is designed as a protocol-independent framework, any protocol is able to integrate with go chassis and leverage same function like load balancing, circuit breaker,rate limiting, routing management, those function resilient your service

  • go chassis makes service observable by bringing open tracing and prometheus to it.

  • go chassis is flexible, many different modules can be replaced by other implementation, like registry, metrics, handler chain, config server etc

  • With many build-in function like route management, circuit breaker, load balancing, monitoring etc, your don't need to investigate, implement and integrate many solutions yourself.

Features

  • Pluggable discovery service: Support Service center, kubernetes. fit both client side discovery and server side discovery pattern, and you can disable service discovery to use end to end communication.
  • Pluggable Protocol: You can customize protocol, by default support http and grpc, go chassis define standardized model to makes all request of different protocol leverage same features
  • Multiple server management: you can separate API by protocols and ports
  • Handler Chain: Able to add your own code during service calling for client and server side
  • rich middleware: based on handler chain, supply circuit breaker, rate limiting, monitoring, auth features. see
  • Traffic marker Traffic marker module is able to mark requests in both client(consumer) or server(provider) side, with marker, you can govern traffic based on it.
  • Traffic management: Able to route to different service based on weight and match rule, it can be used in many scenario, such as canary release
  • Security: build in cipher, authentication, RSA related funtions
  • Safety and resilience: support fault-tolerant(retry, rate limiting, client-side load-balancing, circuit breaker) to makes your service facing any unpredictable situation.
  • Telemetry: Able to expose Prometheus metric API automatically and customize metrics report. Use opentracing-go as standard library.
  • Backing services: use backend service as a plugin, so that your app can be easily tested, and swap to another plugin.
  • Hot re-configuration: Powered by go-archaius, configurations can be reload in runtime, like load balancing, circuit breaker, rate limiting, developer is also able to develop a service which has hot-reconfiguration feature easily. see
  • API first go chassis will automatically generate Open API 2.0 doc and register it to service center. you can manage all the API docs in one place
  • Spring Cloud integrate with servicecomb, go chassis can work together with spring cloud.
  • Service mesh: you can introduce multi-language to your microservice system. powered by servicecomb-mesher.
  • Less dependencies: checkout the go.mod file, it has less dependency on open source project by default, to import more features checkout plugins to see more features

Get started

1.Generate go mod

go mod init

2.Add go chassis

 go get github.com/go-chassis/go-chassis/[email protected]

if you are facing network issue

export GOPROXY=https://goproxy.io

3.Write your first http micro service

Documentations

You can see more documentations in here,

Examples

You can check examples here

NOTICE: Now examples is migrating to here

Communication Protocols

Go-Chassis supports 2 types of communication protocol.

  1. http - an approach that leverages the HTTP protocol for communication.
  2. gRPC - native grpc protocol, go chassis bring circuit breaker, route management etc to grpc.

Debug suggestion for dlv:

Add -tags debug into go build arguments before debugging, if your go version is go1.10 onward.

example:

go build -tags debug -o server -gcflags "all=-N -l" server.go

Chassis customized debug tag to resolve dlv debug issue:

golang/go#23733

https://github.com/derekparker/delve/issues/865

Other project using go-chassis

Known Users

To register your self, go to #592

huawei qutoutiao Shopee
tencent-ieg changhong

Contributing

If you're interested in being a contributor and want to get involved in developing, please check CONTRIBUTING and wiki for details.

Join slack

Committer

  • ichiro999
  • humingcheng

go-chassis's People

Contributors

aseto2016 avatar asifdxtreme avatar daqingshu avatar dengguojie avatar dependabot[bot] avatar gauthamiv avatar goldbeef avatar humingcheng avatar ichiro999 avatar joseph-v avatar kkf1 avatar leikao avatar little-cui avatar liweiv avatar lizihuai avatar ninokop avatar ninotia avatar pinkyo avatar robotljw avatar ryaninvoker avatar shiningrush avatar t-xinlin avatar thandayuthapani avatar tianxiaoliang avatar wangkirin avatar wangqj avatar willemjiang avatar yankooo avatar zhulijian1 avatar zqheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-chassis's Issues

how can i use go-chassis upload and download file?

I want to use go-chassis to dev a micro-service, which can provide upload/download file by http, also my service is more than 2 instances, I also want to loadbalance fuction. If can provide a demo,how to achieve this function?

the writing-rest.md doc need modify

Hello, when I see the doc(docs/getstarted/writing-rest.md) of go-chassic
I find there maybe something need modify like this:
2.修改microservice.yaml
service_description:
name: RESTClient

should be this:

2.修改microservice.yaml

service_description:
  name: RESTClient

after modify,It's maybe display better
I‘m not inconvenient to modify the code, so I set up this issue

(c *chassis) initialize() 初始化顺序问题

if archaius.GetBool("cse.service.registry.disabled", false) != true {
err := registry.Enable()//这里会调用网络请求注册服务
if err != nil {
return err
}
if err := loadbalancer.Enable(); err != nil {
return err
}
}

bootstrap.Bootstrap()

如果使用bootstrap.InstallPlugin("XXX", bootstrap.BootstrapFunc(Init))方式初始化SignRequest func(*http.Request) error 就会有如下错误 :

2018-08-01 11:43:47.751 +08:00 ERROR servicecenter/servicecenter.go:39 Register service [serviceB:0.0.2:lwltest] failed error: RegisterService failed, MicroServiceName/responseStatusCode/responsebody: serviceB/401/{"errorCode":"401002","errorMessage":"Request unauthorized","detail":"Invalid request, header is invalid, ak sk or project is empty."}

分析原因:registry.Enable()会调用服务注册, 进行网络请求需要auth认证,而SignRequest初始化在registry.Enable()请求之后,所以会提示服务中心认证失败。

服务实例异常过后缓存没有刷新,导致请求转发给异常的实例

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Unit test failed with directory mode 0600

I made some unit test with go test, the test always fails complaining "No permission to SOME_DIR", where SOME_DIR is created in the _test.go file with file mode 0600.

As I see from some refs, the execution permission is also needed to access the files insdide the folder, so does it make sense that we change the file mode to 0700?

A test in shell, can't even cd into the folder with mode 0600:

 ~  mkdir perm-test
 ~  chmod 0600 -R perm-test/
 ~cd perm-test/
cd: Permission denied: “./perm-test/”

go get -u github.com/ServiceComb/go-chassis failed

when use go get -u github.com/ServiceComb/go-chassis this response is

package github.com/openzipkin/zipkin-go-opentracing/_thrift/gen-go/zipkincore: cannot find package "github.com/openzipkin/zipkin-go-opentracing/_thrift/gen-go/zipkincore" in any of:
/usr/local/go/src/github.com/openzipkin/zipkin-go-opentracing/_thrift/gen-go/zipkincore (from $GOROOT)
/home/chenghua/go/src/github.com/openzipkin/zipkin-go-opentracing/_thrift/gen-go/zipkincore (from $GOPATH)

When closing one instance of server, it happens error with the client

First, I start two instances of server, then start the client, everything runs great!
Then, I stop one instance of the server, it happens error with the client like this:

{"level":"INFO","timestamp":"2018-01-24 21:22:36.532 +08:00","file":"client/main.go:35","msg":"Hello, Peter"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.540 +08:00","file":"client/main.go:35","msg":"Hello, Peter"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"ERROR","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"handler/transport_handler.go:95","msg":"Call got Error","data":{"error":"EOF"}}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"highway/worker.go:183","msg":"channel is closed"}
{"level":"ERROR","timestamp":"2018-01-24 21:22:36.543 +08:00","file":"client/main.go:33","msg":"error","data":{"error":"EOF"}}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.544 +08:00","file":"client/main.go:35","msg":"Hello, Peter"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.547 +08:00","file":"client/main.go:35","msg":"Hello, Peter"}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.548 +08:00","file":"highway/worker.go:102","msg":"Starting 16 workers for 127.0.0.1:5001"}
{"level":"ERROR","timestamp":"2018-01-24 21:22:36.550 +08:00","file":"handler/transport_handler.go:95","msg":"Call got Error","data":{"error":"dial tcp 127.0.0.1:5001: getsockopt: connection refused"}}
{"level":"ERROR","timestamp":"2018-01-24 21:22:36.550 +08:00","file":"client/main.go:33","msg":"error","data":{"error":"dial tcp 127.0.0.1:5001: getsockopt: connection refused"}}
{"level":"INFO","timestamp":"2018-01-24 21:22:36.550 +08:00","file":"client/main.go:35","msg":"Hello, Peter"}
{"level":"DEBUG","timestamp":"2018-01-24 21:23:01.661 +08:00","file":"servicecenter/cache.go:192","msg":"Cached [1] Instances of service [RPCServer:0.0.1:default] in [production]"}
{"level":"DEBUG","timestamp":"2018-01-24 21:23:31.668 +08:00","file":"servicecenter/cache.go:192","msg":"Cached [1] Instances of service [RPCServer:0.0.1:default] in [production]"}
{"level":"DEBUG","timestamp":"2018-01-24 21:24:01.667 +08:00","file":"servicecenter/cache.go:192","msg":"Cached [1] Instances of service [RPCServer:0.0.1:default] in [production]"}

The source code is like this:

server.go

func main() {
	chassis.RegisterSchema(
		"highway",
		&schemas.GreetingServer{},
		serverOption.WithSchemaID("GreetingService"),
	)

	if err := chassis.Init(); err != nil {
		lager.Logger.Error("Init failed.", err)
	}

	chassis.Run()
}

client.go

func main() {
	if err := chassis.Init(); err != nil {
		lager.Logger.Error("Init failed.", err)
		return
	}

	reply := greeting.GreetingReply{}

	start := time.Now()

	for i := 0; i < 10000; i++ {
		if err := core.NewRPCInvoker().Invoke(
			context.Background(),
			"RPCServer",
			"GreetingService",
			"Say",
			&greeting.GreetingRequest{Name: "Peter"},
			&reply,
		); err != nil {
			lager.Logger.Error("error", err)
		} else {
			lager.Logger.Info(reply.Greeting)
			time.Sleep(time.Microsecond * 500)
		}
	}
	fmt.Println(time.Since(start))
}

greeting.go

// GreetingServer is a struct
type GreetingServer struct {
}

// Say function for GreetingServer
func (s *GreetingServer) Say(ctx context.Context, r *greeting.GreetingRequest) (*greeting.GreetingReply, error) {
	return &greeting.GreetingReply{Greeting: "Hello, " + r.Name}, nil
}

c client and two-way communication

if i want write c/c++ client connect to servicecomb and can two-way communication between c/c++ client and server, what should I do?

go-chassis与go-micro的选择问题

Hi,我们公司计划用go重写一遍我们的服务,目前在选型框架上遇到了问题,不知道go-micro和go-chassis该选哪个。请问你们与go-micro项目优势在哪里?还有你们的功能是对go-micro全覆盖还是相对舍弃了那些功能?

如何在zipkin里显示有依赖关系链式调用?比如a调b,b调c

比如我在例子中的rest server的Sayhello中又调用了RPCServer的HelloService的SayHello方法,运行了rest client程序后,为何在zipkin里没有体现成依赖关系,而是两条独立的调用信息?
tracing配置:
handler:
chain:
Provider:
default: bizkeeper-provider,ratelimiter-provider,tracing-provider
tracing:
enabled: true
collectorType: zipkin
collectorTarget: http://localhost:9411/api/v1/spans

改造后的RestFul Sayhello
//Sayhello is a method used to reply user with hello
func (r *RestFulHello) Sayhello(b *rf.Context) {
id := b.ReadPathParameter("userid")
log.Printf("get user id: " + id)
b.Write([]byte(fmt.Sprintf("user %s from %d", id, num)))
//Init framework
// if err := chassis.Init(); err != nil {
// lager.Logger.Error("Init failed.", err)
// return
// }
//declare reply struct
reply := &helloworld.HelloReply{}
log.Printf("reply", reply)

//Invoke with microservice name, schema ID and operation ID
if err := core.NewRPCInvoker().Invoke(context.Background(), "RPCServer", "HelloService", "SayHello",
	&helloworld.HelloRequest{Name: "Peter"}, reply); err != nil {
	lager.Logger.Error("error", err)

}
// b.Write([]byte(fmt.Sprintf("user-rpc %s from %d", id, num)))
lager.Logger.Info(reply.Message)

}

can't go get

$ go get github.com/ServiceComb/go-chassis
# github.com/ServiceComb/go-chassis/server/restful
../github.com/ServiceComb/go-chassis/server/restful/restful_server.go:34:2: undefined: restful.SetCacheReadEntity

How do I know if the framework started

I wrote the example of communication, but I don't know if it started go-chassis. Because my service center has always been empty. According to the example, what uri to visit is to check it.

我模仿communication例子写的,但我不知道是否启动了go-chassis。因为我的service center 一直是空的。请问按照例子写的是该访问哪个uri查看呢。

image

image

image

image

Any new releases in process?

Hi, I've been struggling with the import path and version for some time. Since the latest tag is 0.6, which still uses github.com/ServiceComb as the organization(refs like github.com/ServiceComb/auth, github.com/ServiceComb/config), so package management tools like dep or glide will still try to install packages under github.com/ServiceComb.

It should be great if we have a version tag higher than 0.6(something like 0.6.1), it's really confusing at the first time when the dependencies problems occur.

concurrent map read and map write for strategy WeightedResponse.

fatal error: concurrent map read and map write

goroutine 59587 [running]:
runtime.throw(0xe7bd21, 0x21)
	/usr/local/go/src/runtime/panic.go:596 +0x95 fp=0xc420bc17a0 sp=0xc420bc1780
runtime.mapaccess1_faststr(0xda6600, 0xc42015f290, 0xc421608bc0, 0x10, 0x0)
	/usr/local/go/src/runtime/hashmap_fast.go:217 +0x4cf fp=0xc420bc1800 sp=0xc420bc17a0
github.com/ServiceComb/go-chassis/core/loadbalancer.(*WeightedResponseStrategy).Pick(0xc4213cc2d0, 0x20, 0xc42068ebd6, 0xb)
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/core/loadbalancer/latency_strategy.go:139 +0x17e fp=0xc420bc1898 sp=0xc420bc1800
github.com/ServiceComb/go-chassis/core/handler.(*LBHandler).getEndpoint(0x13df980, 0xc420e8c600, 0xc421608b70, 0xe6b930, 0xc, 0xc42068fef0, 0x28)
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/core/handler/loadbalance_handler.go:72 +0x3fd fp=0xc420bc1b28 sp=0xc420bc1898
github.com/ServiceComb/go-chassis/core/handler.(*LBHandler).handleWithNoRetry(0x13df980, 0xc4206df700, 0xc420e8c600, 0xc421608b70)
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/core/handler/loadbalance_handler.go:110 +0x43 fp=0xc420bc1b78 sp=0xc420bc1b28
github.com/ServiceComb/go-chassis/core/handler.(*LBHandler).Handle(0x13df980, 0xc4206df700, 0xc420e8c600, 0xc421608b70)
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/core/handler/loadbalance_handler.go:103 +0xb9 fp=0xc420bc1bb0 sp=0xc420bc1b78
github.com/ServiceComb/go-chassis/core/handler.(*Chain).Next(0xc4206df700, 0xc420e8c600, 0xc421608b70)
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/core/handler/handler_chain.go:42 +0x78 fp=0xc420bc1be8 sp=0xc420bc1bb0
github.com/ServiceComb/go-chassis/core/handler.(*RouterHandler).Handle(0x13df980, 0xc4206df700, 0xc420e8c600, 0xc42155f9e0)
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/core/handler/router_handler.go:45 +0x4bf fp=0xc420bc1ea0 sp=0xc420bc1be8
github.com/ServiceComb/go-chassis/core/handler.(*Chain).Next(0xc4206df700, 0xc420e8c600, 0xc42155f9e0)
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/core/handler/handler_chain.go:42 +0x78 fp=0xc420bc1ed8 sp=0xc420bc1ea0
github.com/ServiceComb/go-chassis/core/handler.(*BizKeeperConsumerHandler).Handle.func1(0xc420da2748, 0x7d41b2)
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/core/handler/bizkeeper_consumer_handle.go:54 +0xd6 fp=0xc420bc1f28 sp=0xc420bc1ed8
github.com/ServiceComb/go-chassis/third_party/forked/afex/hystrix-go/hystrix.Do.func1(0xed2541865, 0xc4026f6642)
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/third_party/forked/afex/hystrix-go/hystrix/hystrix.go:179 +0x36 fp=0xc420bc1f58 sp=0xc420bc1f28
github.com/ServiceComb/go-chassis/third_party/forked/afex/hystrix-go/hystrix.Go.func1(0xc4218a9e80, 0xc42155f2c0, 0x14, 0xc4202ccc00, 0xc42155f980)
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/third_party/forked/afex/hystrix-go/hystrix/hystrix.go:124 +0x148 fp=0xc420bc1fb8 sp=0xc420bc1f58
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc420bc1fc0 sp=0xc420bc1fb8
created by github.com/ServiceComb/go-chassis/third_party/forked/afex/hystrix-go/hystrix.Go
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/third_party/forked/afex/hystrix-go/hystrix/hystrix.go:136 +0x22b

goroutine 1 [select, 2 minutes]:
github.com/ServiceComb/go-chassis.Run()
	/home/savita/archaius/src/github.com/ServiceComb/go-chassis/chassis.go:217 +0x73d
main.main()
	/home/savita/archaius/cse-autotest/src/code.huawei.com/cse/assets/go-chassis/go-consumer-with-chassis/main.go:14 +0x27

Error in session stickiness loadbalance strategy

In Session stickiness strategy all user case scenarios are ok except successive failure count.
In successive failure count there is no cookie in the response due to which few of the user error scenarios are not as expected.

内存无限制增长

我们用go-chassis做了个demo进行压力测试,在吞吐量5000左右持续测试,内存一直在增长,最后达到10G以上,测试停止后内存还是维持在高位。

测试demo分三部分,api对外提供接口,restserver和rpcserver提供服务,api接收到请求后请求server,然后把server的结果返回去。测试时,每个服务启动一个,然后jmeter调用api暴露的http接口。具体代码在https://github.com/tomlee0201/chassisdemo

另外抓取了一个prof文件

pprof002.svg.zip

请帮我们确认哪里出了问题,如果有需要补充的信息请提出来

Constraints on microservice version

Hi, I find that the version field defined in conf/microservice.yaml is restricted to be in the format ^[0-9]+(\\.[0-9]+){0,2}$}, while under some environment like kubernetes, the version is usually a label and can be defined with any character. So why does chassis have the constraint? Is it possible that we take version as a common string(like v1, v2 or anything) for flexibility?

This is not inspired by go-micro

This is not inspired by go-micro. It's literally lifting and shifting code. I can see my actual code everywhere. Maybe come discuss how you can leverage go-micro rather than just taking code.

go get error

C:\devtools\java>go get -u github.com/ServiceComb/go-chassis

github.com/ServiceComb/go-chassis/core/lager

C:\cs2mw\workspace\go\src\github.com\ServiceComb\go-chassis\core\lager\lager.go:11:2: log redeclared as imported package name
previous declaration at C:\cs2mw\workspace\go\src\github.com\ServiceComb\go-chassis\core\lager\lager.go:4:2
C:\cs2mw\workspace\go\src\github.com\ServiceComb\go-chassis\core\lager\lager.go:54:2: undefined: "github.com/ServiceComb/paas-lager".Println
C:\cs2mw\workspace\go\src\github.com\ServiceComb\go-chassis\core\lager\lager.go:75:2: undefined: stlager
C:\cs2mw\workspace\go\src\github.com\ServiceComb\go-chassis\core\lager\lager.go:82:12: undefined: stlager
C:\cs2mw\workspace\go\src\github.com\ServiceComb\go-chassis\core\lager\lager.go:97:3: undefined: "github.com/ServiceComb/paas-lager".Println
C:\cs2mw\workspace\go\src\github.com\ServiceComb\go-chassis\core\lager\lager.go:100:3: undefined: "github.com/ServiceComb/paas-lager".Printf

benchmark问题

我们使用benchmark测试,发现如下问题

2018-08-01 10:05:32.313 +08:00 INFO highway/highway_base_client.go:77 GetClient from new open addr:127.0.0.1:8082
2018-08-01 10:05:32.322 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.322 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.331 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.331 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.336 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.337 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.349 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.349 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.457 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.457 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.462 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.462 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.465 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.466 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.491 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.491 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.497 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.497 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.516 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.516 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.555 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.555 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.620 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.620 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.630 +08:00 ERROR highway/highway_msgobj.go:238 Unmarshal response body  failed error: proto: invalid UTF-8 string
2018-08-01 10:05:32.630 +08:00 ERROR highway/highway_msgobj.go:201 Frame head error. error: Invalid magicID
Error have occured:  Expected Msg: , But: 
2018-08-01 10:05:32.630 +08:00 ERROR highway/highway_base_client.go:242 AsyncSendMsg err: error: write tcp 127.0.0.1:49353->127.0.0.1:8082: use of closed network connection
2018-08-01 10:05:32.630 +08:00 ERROR handler/transport_handler.go:47 Call got Error error: write tcp 127.0.0.1:49353->127.0.0.1:8082: use of closed network connection
panic: write tcp 127.0.0.1:49353->127.0.0.1:8082: use of closed network connection

goroutine 92 [running]:
main.Call(0xbed0633b12d012be, 0x178d650, 0x4fbac20, 0xc42000c240, 0x0, 0x0, 0x0, 0x4a158c6, 0x7, 0x4e20, ...)
	/Users/heavyrainlee/go/src/github.com/go-chassis/go-chassis/benchmark/client/main.go:141 +0x9ce
created by main.main
	/Users/heavyrainlee/go/src/github.com/go-chassis/go-chassis/benchmark/client/main.go:115 +0x5e4

测试使用的是highway,测试方法就是修改benchmark/client/conf/test.yaml,把最后一行改为

protocol: highway

复现概率为偶现,10次能出1次的大概概率

import cycle

github.com/ServiceComb/go-chassis/metrics import: "github.com/ServiceComb/cse-collector"

"github.com/ServiceComb/cse-collector" import: github.com/ServiceComb/go-chassis/metrics

FindMicroServiceInstances指定被查询的服务版本为latest(非指定版本)时有问题,被查询的服务实例有变化时,再调用此接口,查询的实例信息还是老的

`func (r *Servicecenter) FindMicroServiceInstances(consumerID, appID, microServiceName, version string) ([]*registry.MicroServiceInstance, error) {
key := microServiceName + ":" + version + ":" + appID
value, boo := registry.MicroserviceInstanceCache.Get(key)
if !boo || value == nil {
//Try remote
lager.Logger.Warnf(nil, "%s Get instances from remote, key: %s", consumerID, key)
providerInstances, err := r.registryClient.FindMicroServiceInstances(consumerID, appID, microServiceName, version, config.Stage)
if err != nil {
return nil, fmt.Errorf("FindMicroServiceInstances failed, ProviderID: %s, err: %s", key, err)
}
instances := filterInstances(providerInstances)

	registry.MicroserviceInstanceCache.Set(key, instances, 0)
	return instances, nil
}
fmt.Println("key = ", key, ", cache = ", value.([]*registry.MicroServiceInstance))
microServiceInstance, ok := value.([]*registry.MicroServiceInstance)
if !ok {
	lager.Logger.Errorf(nil, "FindMicroServiceInstances failed, Type asserts failed.consumerIDL: %s", consumerID)
}
return microServiceInstance, nil

}`

key := microServiceName + ":" + version + ":" + appID

查询实例的时候指定版本是latest,缓存就是“xxxx:latest:123”来存的,但是如果服务故障,推送服务实例刷新事件的时候版本是真实的“xxxx:1.0.1:123”这样存的

func deleteAction(response *model.MicroServiceInstanceChangedEvent) { key := response.Key.ServiceName + ":" + response.Key.Version + ":" + response.Key.AppID value, ok := registry.MicroserviceInstanceCache.Get(key) if !ok { lager.Logger.Errorf(nil, "ServiceID does not exist in MicroserviceInstanceCache,action is EVT_DELETE, key = %s", key) return } microServiceInstances, ok := value.([]*registry.MicroServiceInstance) if !ok { lager.Logger.Errorf(nil, "Type asserts failed.action is EVT_DELETE,sid = %s", response.Instance.ServiceID) return } var newInstances []*registry.MicroServiceInstance = make([]*registry.MicroServiceInstance, 0) for _, v := range microServiceInstances { if v.InstanceID != response.Instance.InstanceID { newInstances = append(newInstances, v) } } registry.MicroserviceInstanceCache.Set(key, newInstances, 0) lager.Logger.Debugf("Cached Instances,action is EVT_DELETE,sid = %s, instances length = %d", response.Instance.ServiceID, len(newInstances)) }

再查latest的时候,一直使用的是cache,不刷新

Highway有出现以下错误

遇到highway的报错:
{"level":"DEBUG","timestamp":"2018-04-02 11:08:26.184 +08:00","file":"handler/tracing_handler.go:89","msg":"opentracing: SpanContext not found in Extract carrier"}
{"level":"ERROR","timestamp":"2018-04-02 11:08:26.185 +08:00","file":"highway/highway_msgobj.go:188","msg":"Recv Frame head failed.","data":{"error":"EOF"}}
{"level":"ERROR","timestamp":"2018-04-02 11:08:26.185 +08:00","file":"highway/highway_msgobj.go:188","msg":"Recv Frame head failed.","data":{"error":"EOF"}}
或者:
2018-04-03 13:40:20.220 +08:00 ERROR highway/highway_msgobj.go:188 Recv Frame head failed. error: read tcp 127.0.0.1:8082->127.0.0.1:56483: use of closed network connection

glide install error

glide install in go-chassis dir:

[INFO]	--> Fetching updates for github.com/kr/logfmt
[ERROR]	Failed to retrieve a list of dependencies: Error resolving imports

image

tls用法是否可以更灵活一些?

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
tls,例如服务A作为consumer,服务B和C作为provider,B服务开启tls,C服务也开启tls,需要A服务在配置文件tls.yaml分别提前指定调用B服务用证书,指定调用C服务使用证书等,是否可以做个通配的证书,同时根据endpoint自动识别provider服务实例是否开启tls,开启的话就用证书文件对接,不开启tls就不用tls对接。这样灵活性更高。

Describe the solution you'd like
A clear and concise description of what you want to happen.
通配的证书,同时根据endpoint自动识别provider服务实例是否开启tls,开启的话就用证书文件对接,不开启tls就不用tls对接。

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

UT is failing for tracing handler

2018/01/18 15:39:49 <nil>
2018/01/18 15:39:49 Enable log tool
2018/01/18 15:39:50 Enable log tool
--- FAIL: TestTracingHandler_Rest_RestRequest (0.20s)
	tracing_handler_test.go:221: ========tracing [consumer] handler [rest]
	tracing_handler_test.go:245: ====span should be stored in context after invoker
	tracing_handler_test.go:248: ====spanContext stored in context should be the same with monitor received
        Error Trace:    tracing_handler_test.go:250
	Error:      	Not equal: 
	            	expected: 1
	            	actual  : 0
	Test:       	TestTracingHandler_Rest_RestRequest

Failed to run go-chassis based application under kubernetes

Hi all, I'm trying to run my go-chassis based applications in a kubernetes cluster. The individual micro-services are running in k8s pod and accessed by k8s services, so I configure the provider's --advertiseAddress to be the domain name(service name plus namespace in k8s). But the advertisementAddress is only allowed to be a CIDR IP address, according to the code around here, so the service cannot be registered in the service center.

As I understand(might not be correct), when a service register itself in the service center, the --advertiseAddress is stored and dispatched to other services to make the registering service accessible. So the address might not only be a CIDR IP, but also domain names, IPv6 address, or even Unix socket under some special situation.

Any ideas on this?

route-rule fails for darklaunch if we don't give weight.

Configuration is

{
  "policyType": "RULE",
  "ruleItems": [
    {
      "groupName": "s2",
      "groupCondition": "version=0.0.1",
      "policyCondition": "test=40"
    },
    {
      "groupName": "s1",
      "groupCondition": "version=0.4",
      "policyCondition": "test!=40"
    }
  ]
}

Root Cause:

https://github.com/ServiceComb/go-chassis/blob/master/core/router/router_config.go#L64
In
validateRule(rules map[string][]*model.RouteRule) bool
function if we don't provide weight by default it will take 100% so as per the above configuration first time weight become 100 and in the second iteration it becomes 200
https://github.com/ServiceComb/go-chassis/blob/master/core/router/router_config.go#L74
Because of this condition validateRule function returns false.
So the version will be allways latest and not the one which has been given in the configuration like
0.0.1 or 0.4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.