etcdnaming

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

README

etcdnaming

a tool which using ectd for some clients to find server when its started

etcd & grpc

installation

  • fisrt

github.com/coreos/go-systemd v22.0.0

go get github.com/coreos/go-systemd
  • than: added this into go.mod
replace github.com/coreos/go-systemd => $GOPATH/src/github.com/coreos/go-systemd
  • last:
go get github.com/go-trellis/etcdnaming

Server

server example

Client

client example

Documentation

Index

Constants

View Source
const (

	// DialTarget 访问目标
	DialTarget = schema + ":///"
)

Variables

This section is empty.

Functions

func Dial

func Dial(opts ...grpc.DialOption) (*grpc.ClientConn, error)

Dial 拨号

func DialContext

func DialContext(ctx context.Context, opts ...grpc.DialOption) (*grpc.ClientConn, error)

DialContext 带上下文的拨号

func NewBuilder

func NewBuilder(opt BuilderOptions)

NewBuilder 获取builder

Types

type BuilderOptions added in v1.0.1

type BuilderOptions struct {
	Server     string
	Version    string
	Endpoint   string
	LooperTime time.Duration
}

BuilderOptions builder's configure

type ServerRegister

type ServerRegister interface {
	// Regist 注册服务
	Regist() error
	// Revoke 注销服务
	Revoke() error
}

ServerRegister regist or revoke server interface

func NewDefaultServerRegister

func NewDefaultServerRegister(c ServerRegisterConfig) ServerRegister

NewDefaultServerRegister instance of server regitster

type ServerRegisterConfig

type ServerRegisterConfig struct {
	Name             string
	Target           string
	Service          string // host & port
	Version          string // server's version
	TTL              time.Duration
	Interval         time.Duration
	RegistRetryTimes int
	// contains filtered or unexported fields
}

ServerRegisterConfig struct server regiter config name: server name target: etcd' client url, separate by ',' serv: server address host:port interval: Rotation time to registe serv into etcd ttl: expired time, seconds registRetryTimes: allow failed to regist server and retry times; -1 alaways retry

Directories

Path Synopsis
proto
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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