sccli

package
v0.0.0-...-63b2ac5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2019 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	XinsecureDialOption = NewDialOptionBuilder(grpc.WithInsecure())
)

Functions

func GrpcDial

func GrpcDial(network, addr string) (*grpc.ClientConn, error)

grpc dial ,以后可以进行通用性的封装

Types

type DialOptionBuilder

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

func NewDialOptionBuilder

func NewDialOptionBuilder(option grpc.DialOption) *DialOptionBuilder

func (*DialOptionBuilder) ToDialOption

func (this *DialOptionBuilder) ToDialOption() []grpc.DialOption

有一个结构体组, 用来保存多个option. 最后在会返回出去

type Dialer

type Dialer interface {
	ContextDialer(ctx context.Context, addr string) (net.Conn, error)
	Dialer(addr string) (net.Conn, error)
}

func NewDialer

func NewDialer(network, addr string) (dialer Dialer, err error)

func NewTcpDialer

func NewTcpDialer(addr string) (dialer Dialer, err error)

func NewUnixDialer

func NewUnixDialer(addr string) (dialer Dialer, err error)

----------start----------构造函数----------start----------

type LisAddr

type LisAddr struct {
	Address     string
	AddressType services.AddressType
}

func (*LisAddr) Listener

func (this *LisAddr) Listener() (net.Listener, error)

func (*LisAddr) Rand

func (this *LisAddr) Rand(network string) *LisAddr

随机为指定的地址

type ScCli

type ScCli interface {
	// 向服务中心注册该服务
	Register() error

	// 启动服务(不阻塞)
	Start()

	// 等待服务结束
	Wait() error
}

func NewScCli

func NewScCli(info *ServiceInfo, runtimeInfo *ServiceRuntimeInfo) (ScCli, error)

----------start----------构造函数----------start----------

type ServiceInfo

type ServiceInfo struct {
	// 服务名称
	Name string
	// 服务自定义code
	Code string
	// 服务一句话描述信息
	Describe string
	// 服务备注信息
	Remark string

	// 连接地址
	Addr string

	AddrNetwork string
	// contains filtered or unexported fields
}

func NewRandServiceInfo

func NewRandServiceInfo() *ServiceInfo

----------start----------构造函数----------start---------- 随机生成并返回一个serviceInfo

func NewServiceInfo

func NewServiceInfo() *ServiceInfo

func (*ServiceInfo) Serve

func (this *ServiceInfo) Serve(f func(server *grpc.Server))

type ServiceRuntimeInfo

type ServiceRuntimeInfo struct {
	ServiceId       uint32
	ServiceVersion  uint32
	ServiceBootTime int64
	ServiceBootCode string
	//
	// 监听的地址
	Addr net.Addr
	// contains filtered or unexported fields
}

func NewRuntimeInfoWithSI

func NewRuntimeInfoWithSI(info *ServiceInfo) (*ServiceRuntimeInfo, error)

NewRuntimeInfoWithSserviceInfo

func NewServiceRuntimeInfo

func NewServiceRuntimeInfo() *ServiceRuntimeInfo

----------start----------构造函数----------start----------

type SimpleDialer

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

func (*SimpleDialer) ContextDialer

func (dia *SimpleDialer) ContextDialer(ctx context.Context, addr string) (net.Conn, error)

func (*SimpleDialer) Dialer

func (dia *SimpleDialer) Dialer(addr string) (net.Conn, error)

type SimpleScCli

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

func (*SimpleScCli) Register

func (cli *SimpleScCli) Register() error

注册服务

func (*SimpleScCli) Start

func (cli *SimpleScCli) Start()

启动服务

func (*SimpleScCli) Wait

func (cli *SimpleScCli) Wait() error

Jump to

Keyboard shortcuts

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