chassis

package module
v0.0.0-...-5e0f84c Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2018 License: Apache-2.0 Imports: 30 Imported by: 0

README

Go-chassis

Build Status Coverage Status 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.

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(protocol string, structPtr interface{}, opts ...serverOption.RegisterOption)

RegisterSchema Register a API service to specific protocol You must register API first before Call Init

func Run

func Run()

Run bring up the service,it will not return error,instead just waiting for os signal,and shutdown gracefully

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
highway/pb
Package highway is a generated protocol buffer package.
Package highway is a generated protocol buffer package.
lager
Package lager is the package for lager
Package lager is the package for lager
loadbalance
Package loadbalance is a way to load balance service nodes
Package loadbalance is a way to load balance service nodes
metadata
Package metadata provides framework info registered to registry.
Package metadata provides framework info registered to registry.
tls
examples
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.
Package security created on 2017/6/22
Package security created on 2017/6/22
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/afex/hystrix-go/loadtest/service
Package main implements an http server which executes a hystrix command each request and sends metrics to a statsd instance to aid performance testing.
Package main implements an http server which executes a hystrix command each request and sends metrics to a statsd instance to aid performance testing.
forked/afex/hystrix-go/plugins
Plugins allows users to operate on statistics recorded for each circuit operation.
Plugins allows users to operate on statistics recorded for each circuit operation.
forked/go-micro/client
Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package client is an interface for any protocol's client
Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package client is an interface for any protocol's client
forked/go-micro/codec
Package codec is an interface for encoding messages
Package codec is an interface for encoding messages
forked/go-micro/metadata
Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package metadata is a way of defining message headers
Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package metadata is a way of defining message headers
forked/go-micro/selector
Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package loadbalance is a way to load balance service nodes
Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package loadbalance is a way to load balance service nodes
forked/go-micro/server
Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package server is an interface for a micro server
Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package server is an interface for a micro server
forked/go-micro/transport/tcp
Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package tcp provides a TCP transport Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package tcp provides a TCP transport
Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package tcp provides a TCP transport Forked from github.com/micro/go-micro Some parts of this file have been modified to make it functional in this package Package tcp provides a TCP transport
forked/valyala/fasthttp
Package fasthttp provides fast HTTP server and client API.
Package fasthttp provides fast HTTP server and client API.
forked/valyala/fasthttp/examples/fileserver
Example static file server.
Example static file server.
forked/valyala/fasthttp/expvarhandler
Package expvarhandler provides fasthttp-compatible request handler serving expvars.
Package expvarhandler provides fasthttp-compatible request handler serving expvars.
forked/valyala/fasthttp/fasthttpadaptor
Package fasthttpadaptor provides helper functions for converting net/http request handlers to fasthttp request handlers.
Package fasthttpadaptor provides helper functions for converting net/http request handlers to fasthttp request handlers.
forked/valyala/fasthttp/fasthttputil
Package fasthttputil provides utility functions for fasthttp.
Package fasthttputil provides utility functions for fasthttp.
forked/valyala/fasthttp/reuseport
Package reuseport provides TCP net.Listener with SO_REUSEPORT support.
Package reuseport provides TCP net.Listener with SO_REUSEPORT support.
util

Jump to

Keyboard shortcuts

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