framework

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2021 License: MIT Imports: 13 Imported by: 1

README

RPCX Framework

Go Report Card MIT license Build Status Foundation GoDoc Sourcegraph Release TODOs goproxy.cn

An RPC microservices framework based on rpcx.

Features: simple and easy to use, ultra fast and efficient, powerful, service discovery, service governance, service layering, version control, routing label registration.

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it!

Java有Dubbo, Golang有RPCX!

Installation

To install rpcx-framework package, you need to install Go and set your Go workspace first.

  1. The first need Go installed (version 1.11+ is required), then you can use the below Go command to install rpcx-framework.
$ go get -u github.com/ZYallers/rpcx-framework
  1. Import it in your code:
import "github.com/ZYallers/rpcx-framework" 

Examples

The below is a simple example.

package main

import (
	"github.com/smallnest/rpcx/log"
	framework "gitlab.sys.hxsapp.net/hxs/rpcx-framework"
)

func init() {
	framework.LoadConfig()
}

func main() {
	//share.Trace = true
	s := framework.NewService()
	log.Infof("Service-> %+v; Etcd-> %+v", *s, *(s.Etcd))
	s.Serve()
}

How to deploy and run?

Copy the boot script "script / bootstrap. Sh" to the root directory of your project, and then execute it; If successful, you will see the following information:

 current path: /Users/cloud/gopath_hxsapp/rpcx-demo 
 download produce.sh 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  7791  100  7791    0     0    221      0  0:00:35  0:00:35 --:--:--  1904
 download produce.sh(/Users/cloud/gopath_hxsapp/rpcx-demo/./bin/produce.sh) finished 
 service config: 
 ServiceName: rpcx-demo 
 ServiceAddr: 172.18.28.123:8978 
 LogDir: /apps/logs/go/rpcx-demo 
 Operation: 
     status                                  View service status
     sync                                    Synchronization service vendor resources
     build                                   Compile and generate service program
     reload                                  Smooth restart service
     quit                                    Stop service
     help                                    View help information for the help command
 For more information about an action, use the help command to view it

At the same time, after successful execution, it will create a new bin directory in your current directory, and generate a service compilation and deployment script produce sh

Execute the deployment script ./bin/produce.sh help, it will tell you what to do next.

 service config: 
 ServiceName: rpcx-demo 
 ServiceAddr: 172.18.28.123:8978 
 LogDir: /apps/logs/go/rpcx-demo 
 Operation: 
     status                                  View service status
     sync                                    Synchronization service vendor resources
     build                                   Compile and generate service program
     reload                                  Smooth restart service
     quit                                    Stop service
     help                                    View help information for the help command
 For more information about an action, use the help command to view it

Feature

An RPC service framework based on rpcx (fast, easy-to-use but powerful RPC service governance framework of go language).

  • easy to use
  • super fast and efficient
  • powerful
  • service discovery
  • service governance
  • service layering
  • version control
  • routing label registration.
RPCX

rpcx is a RPC framework like Alibaba Dubbo and Weibo Motan.

rpcx is created for targets:

  1. Simple: easy to learn, easy to develop, easy to intergate and easy to deploy
  2. Performance: high perforamnce (>= grpc-go)
  3. Cross-platform: support raw slice of bytes, JSON, Protobuf and MessagePack. Theoretically it can be used with java, php, python, c/c++, node.js, c# and other platforms
  4. Service discovery and service governance: support zookeeper, etcd and consul.

It contains below features

  • Support raw Go functions. There's no need to define proto files.
  • Pluggable. Features can be extended such as service discovery, tracing.
  • Support TCP, HTTP, QUIC and KCP
  • Support multiple codecs such as JSON, Protobuf, MessagePack and raw bytes.
  • Service discovery. Support peer2peer, configured peers, zookeeper, etcd, consul and mDNS.
  • Fault tolerance:Failover, Failfast, Failtry.
  • Load banlancing:support Random, RoundRobin, Consistent hashing, Weighted, network quality and Geography.
  • Support Compression.
  • Support passing metadata.
  • Support Authorization.
  • Support heartbeat and one-way request.
  • Other features: metrics, log, timeout, alias, circuit breaker.
  • Support bidirectional communication.
  • Support access via HTTP so you can write clients in any programming languages.
  • Support API gateway.
  • Support backup request, forking and broadcast.

Reference

License

Released under the MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoveryAddress

func DiscoveryAddress() []string

func DiscoveryBasePath

func DiscoveryBasePath() string

func DiscoveryUpdateInterval

func DiscoveryUpdateInterval() time.Duration

func LoadConfig

func LoadConfig(args ...string)

func NewService

func NewService() *service.RPCXService

func ReadConfig

func ReadConfig(key string) string

func ServiceHostName

func ServiceHostName() string

func ServiceMode

func ServiceMode() string

func ServiceName

func ServiceName() string

Types

This section is empty.

Directories

Path Synopsis
util
zap

Jump to

Keyboard shortcuts

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