gracefulrpc

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

gracefulrpc

基于golang的rpc服务,使用tcp传输协议,支持gob, json, protobuf编解码器,同时支持零停机重启。

使用

go get -u github.com/phprao/gracefulrpc

零停机部署

信号:

  • SIGHUP 平滑重启
  • SIGTERM 平滑停止
  • SIGINT 立即停止

平滑停止和平滑重启默认延迟一分钟,可以设置。同时你还可以Writer对象来满足日志记录的需要。

DEMO

rpc_gob
rpc_json
rpc_protobuf

Documentation

Overview

-- @Time : 2020/11/9 9:55 -- @Author : raoxiaoya -- @Desc :

Index

Constants

View Source
const (
	STATUS_RUNNING  uint8 = 1
	STATUS_STOPPING uint8 = 2
	STATUS_STOPED   uint8 = 3

	GRACERPC_KEY = "GRACERPC_RESTART"
)

Variables

View Source
var DefaultWriter = log.New(os.Stdout, "", log.LstdFlags)

Functions

func ListenAndServe

func ListenAndServe(network string, address string) error

func NewServer

func NewServer(gc Config) (server *gracerpcServer)

Types

type Config

type Config struct {
	DelayTime time.Duration
	Logger    Writer
	CodecType string
}

type Writer

type Writer interface {
	Println(v ...interface{})
	Printf(string, ...interface{})
}

Directories

Path Synopsis
repo
-- @Time : 2020/11/3 14:41 -- @Author : raoxiaoya -- @Desc :
-- @Time : 2020/11/3 14:41 -- @Author : raoxiaoya -- @Desc :
repo
-- @Time : 2020/11/3 14:41 -- @Author : raoxiaoya -- @Desc :
-- @Time : 2020/11/3 14:41 -- @Author : raoxiaoya -- @Desc :
pbs
repo
-- @Time : 2020/11/3 14:41 -- @Author : raoxiaoya -- @Desc :
-- @Time : 2020/11/3 14:41 -- @Author : raoxiaoya -- @Desc :

Jump to

Keyboard shortcuts

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