gorpc

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: MIT Imports: 12 Imported by: 0

README

1.github上下载一个cpp包:https://github.com/google/protobuf/releases make make install安装即可

$ wget https://github.com/protocolbuffers/protobuf/releases/download/v3.13.0/protobuf-cpp-3.13.0.tar.gz
$ tar xvfz protobuf-cpp-3.13.0.tar.gz
$ cd protobuf-cpp-3.13.0
$ make && make install
  1. 安装go插件 protoc-gen-go
$ go get -u github.com/golang/protobuf/protoc-gen-go

3.安装go-micro插件 protoc-gen-micro

$ go get github.com/micro/protoc-gen-micro
  1. 启动consul
  • Windows
@echo off
consul agent -server -bootstrap-expect 1 -data-dir .\data -node=s1 -bind=127.0.0.1 -http-port=8500  -dns-port=5600 -rejoin -config-dir=.\etc\consul.d -client 0.0.0.0
pause
  • Linux
$ sudo mkdir -p /data/consul
$ sudo chmod 0777 /data/consul
nohup consul agent -server -bootstrap-expect 1 -data-dir /data/consul -node=s1 -bind=127.0.0.1 -http-port=8500  -dns-port=8600 -rejoin -config-dir=/etc/consul.d/ -client 0.0.0.0 > /tmp/consul.log 2>&1 &

Documentation

Index

Constants

View Source
const (
	DISCOVERY_DEFAULT_INTERVAL = 3
	DISCOVERY_DEFAULT_TTL      = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Discovery

type Discovery struct {
	ServiceName string   // register service name [required]
	RpcAddr     string   // register server RPC address [required]
	Interval    int      // register interval default 3 seconds [optional]
	TTL         int      // register TTL default 10 seconds [optional]
	Endpoints   []string // register endpoints of etcd/consul/zookeeper eg. ["192.168.0.10:2379","192.168.0.11:2379"]
}

type EndpointType

type EndpointType int
const (
	EndpointType_MDNS      EndpointType = 0 // multicast DNS
	EndpointType_ETCD      EndpointType = 1 // etcd
	EndpointType_CONSUL    EndpointType = 2 // consul
	EndpointType_ZOOKEEPER EndpointType = 3 // zookeeper
)

func (EndpointType) String

func (t EndpointType) String() string

type GoRPC

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

func NewGoRPC

func NewGoRPC(endpointType EndpointType) (g *GoRPC)

func (*GoRPC) NewClient

func (g *GoRPC) NewClient(endPoints ...string) (c client.Client)

new a go-micro client

func (*GoRPC) NewServer

func (g *GoRPC) NewServer(discovery *Discovery) (s server.Server)

new a go-micro server

Directories

Path Synopsis
example
client command
server command

Jump to

Keyboard shortcuts

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