Go-Chassis is a Software Development Kit(SDK) for rapid development of microservices in GoLang, providing service-discovery, fault-tolerance, circuit breaker, load balancing, monitoring, hot-reconfiguration features
Inspired by Go-Micro A pluggable RPC framework for distributed systems development.
Go-chassis is not a enhancement based on it, but did something more
- Pluggable registry: Support Service center and file based registry by default
- Dynamic Configuration framework: you are able to develop a service which has hot-reconfiguration feature easily
- Pluggable Protocol: You can custom your own protocol,by default support http and highway(RPC)
- Circuit breaker: Protect your service in runtime or on-demand
- Load balancing: You can custom strategy and filter
- Rate limiting: Both client side and server side rate limiting
- Pluggable Cipher: Able to custom your own cipher for AKSK and TLS certs
- Handler Chain: Able to add your own code during service calling for client and server side
- Metrics: Able to expose Prometheus metric API automatically and sink metrics to CSE Dashboard
- Tracing: Integrate with Zipkin and namedpipe to sink tracing data
- Logger: You can custom your own writer to sink log, by default support file and stdout
- Hot-reconfiguraion: A lot of configuration can be reload in runtime, like loadbalancing, circuit breaker, rate limiting
You can see more informations in gitbook https://go.huaweicse.cn/
Step 1: Define your Schema and your business logic.
//API
func (s *HelloServer) SayHello(b *restful.Context) {
b.Write([]byte("Hello : Welcome to Go-Chassis."))
}
//Specify URL pattern
func (s *HelloServer) URLPatterns() []restful.Route {
return []restful.Route{
{http.MethodGet, "/sayhello", "SayHello"},
}
}
Step 2: Register your Schema to go-chassis
chassis.RegisterSchema("rest", &HelloServer{},
server.WithSchemaID("HelloServer"))
Step 3: Start the Chassis as a Server
chassis.Init()
chassis.Run()
Step 1: Initialize your Chassis
chassis.Init()
Step 2: Use Rest Invoker to call the provider
restinvoker := core.NewRestInvoker()
req, _ := rest.NewRequest("GET", "cse://"+providerName+"/sayhello")
resp1, err := restinvoker.ContextDo(context.TODO(), req)
You can check examples here
Go-Chassis supports two types of communication protocol.
- Rest - REST is an approach that leverages the HTTP protocol for communication.
- Highway - This is a high performance communication protocol originally developed by Huawei.