chassis

package module
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2019 License: Apache-2.0 Imports: 37 Imported by: 18

README

Build Status Coverage Status Go Report Card GoDoc HitCount Join Slack

Go-Chassis is a microservice framework for rapid development of microservices in Go

Why use Go chassis

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 bring 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 center 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.

go chassis supports Istio platform, Although Istio is a great platform with a service mesh in data plane, it surely decrease the throughput and increase the latency of your service go chassis can bring better performance to go program, you can use Istio configurations to control go chassis.

Go chassis also has a service mesh solution https://github.com/go-mesh/mesher, it is build on top of go chassis. you can use same registry, configuration to goven all of service written in different language.

Features

  • Pluggable registrator and discovery service: Support Service center, istio pilot, kubernetes and file based registry, fit both client side discovery and server side discovery pattern
  • Pluggable Protocol: You can custom your own protocol, by default support http and grpc
  • Multiple server management: you can separate API by protocols and ports
  • Circuit breaker: Protect your micro service system in runtime
  • Route management: Able to route to different service based on weight and match rule to achieve Canary Release easily
  • Client side Load balancing: Able to custom strategy
  • 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 custom metrics reporter
  • Tracing:Use opentracing-go as standard library, easy to integrate tracing impl
  • Logger: You can custom your own writer to sink log, by default support file and stdout
  • Hot-reconfiguraion: Powered by go-archaius, configurations can be reload in runtime, like load balancing, circuit breaker, rate limiting
  • Dynamic Configuration framework: Powered by go-archaius, developer is able to develop a service which has hot-reconfiguration feature easily
  • Fault Injection: In consumer side, you can inject faults to bring chaos testing into your system

You can check plugins to see more features

Quick Start

You can see more documentations in here, this doc is for latest version of go chassis, if you want to see your version's doc, follow here to generate it

  1. Install go 1.10+

  2. Clone the project

git clone git@github.com:go-chassis/go-chassis.git
  1. Use go mod(go 1.11+, experimental but a recommended way)
cd go-chassis
export GO111MODULE=on 
go mod download
#optional
export GO111MODULE=on 
go mod vendor

NOTICE:if you do not use mod, We can not ensure you the compatibility. however you can still maintain your own vendor, which means you have to solve compiling issue your own.

  1. Install service-center

  2. Write your first http micro service

Examples

You can check examples here

NOTICE: Now examples is migrating to here

Communication Protocols

Go-Chassis supports 3 types of communication protocol.

  1. Rest - REST is an approach that leverages the HTTP protocol for communication.
  2. Highway - This is a RPC communication protocol, it was deprecated.
  3. 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:

https://github.com/golang/go/issues/23733

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

Eco system

this part introduce some eco systems that go chassis can run with

Apache ServiceComb

With ServiceComb service center as registry, go chassis supply more features like contract management and multiple service registry, highly recommended. that will not prevent you from using kubernetes or Istio, Because service center can aggregate heterogeneous registry and give you a unified service registry entry point.

Kubenetes and Istio

go chassis has k8s registry and Istio registry plugins, and support Istio traffic management you can use spring cloud or Envoy with go chassis under same service discovery service.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init() error

Init prepare the chassis framework runtime

func RegisterSchema

func RegisterSchema(serverName string, structPtr interface{}, opts ...server.RegisterOption)

RegisterSchema Register a API service to specific server by name You must register API first before Call Init

func Run

func Run() error

Run bring up the service,it waits for os signal,and shutdown gracefully before all protocol server start successfully, it may return error.

func SetDefaultConsumerChains

func SetDefaultConsumerChains(c map[string]string)

SetDefaultConsumerChains your custom chain map for Consumer,if there is no config, this default chain will take affect

func SetDefaultProviderChains

func SetDefaultProviderChains(c map[string]string)

SetDefaultProviderChains set your custom chain map for Provider,if there is no config, this default chain will take affect

Types

type Schema

type Schema struct {
	// contains filtered or unexported fields
}

Schema struct for to represent schema info

Directories

Path Synopsis
client
client
Package client is an interface for any protocol's client
Package client is an interface for any protocol's client
lager
Package lager is the package for lager
Package lager is the package for lager
loadbalancer
Package loadbalancer is client side load balancer
Package loadbalancer is client side load balancer
metadata
Package metadata provides framework info registered to registry.
Package metadata provides framework info registered to registry.
router
Package router expose API for user to get or set route rule
Package router expose API for user to get or set route rule
server
Package server is a package for protocol of a micro service
Package server is a package for protocol of a micro service
tls
examples
circuit/client command
circuit/server command
metadata command
pilot/client command
pilot/server command
rest/client command
rest/server command
rpc/client command
rpc/server command
schemas/employ
Package employ is a generated protocol buffer package.
Package employ is a generated protocol buffer package.
schemas/helloworld
Package helloworld is a generated protocol buffer package.
Package helloworld is a generated protocol buffer package.
healthz
Package initiator init necessary module before every other package init functions
Package initiator init necessary module before every other package init functions
Package metrics bootstrap metrics reporter, and supply a metrics registries powered by rcrowley/go-metrics there is a default registry "default_metric_registry" which saves go chassis runtime metrics you can report them to varies monitoring system by install Reporter plugin
Package metrics bootstrap metrics reporter, and supply a metrics registries powered by rcrowley/go-metrics there is a default registry "default_metric_registry" which saves go chassis runtime metrics you can report them to varies monitoring system by install Reporter plugin
pkg
plugins/plain
Package plain created on 2017/6/22
Package plain created on 2017/6/22
server
third_party
forked/afex/hystrix-go/hystrix
Package hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
Package hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
forked/k8s.io/apimachinery/pkg/util/rand
Package rand provides utilities related to randomization.
Package rand provides utilities related to randomization.
forked/k8s.io/apimachinery/pkg/util/sets
Package sets has auto-generated set types.
Package sets has auto-generated set types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL