Skip to content

Go-Chassis is a Software Development Kit(SDK) for rapid development of microservices in Go

License

Notifications You must be signed in to change notification settings

joseph-v/go-chassis

 
 

Repository files navigation

Go-Chassis

Build Status Coverage Status Go Report Card GoDoc HitCount

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

Go-chassis is based on Go-Micro A pluggable RPC framework, and did some enhancements.

Features

  • 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
  • Routing management: Able to route to different service based on weight and match rule to achieve Canary Release easily
  • Load balancing: Add 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

Quick Start

You can see more informations in gitbook https://go.huaweicse.com/

Write a http service provider

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()

Write a Http Consumer

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)

Examples

You can check examples here

Communication Protocols

Go-Chassis supports two types of communication protocol.

  1. Rest - REST is an approach that leverages the HTTP protocol for communication.
  2. Highway - This is a high performance communication protocol originally developed by Huawei.

About

Go-Chassis is a Software Development Kit(SDK) for rapid development of microservices in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.3%
  • Shell 0.7%