discovery

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

README

discovery

A service discovery module implemented by ETCD.

Documentation

Overview

Package discovery is the service discovery module implemented by ETCD.

Copyright 2018 HenryLee. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLinker

func NewLinker(etcdConfig etcd.EasyConfig) micro.Linker

NewLinker creates a etct service linker. Note: If etcdConfig.DialTimeout<0, it means unlimit; If etcdConfig.DialTimeout=0, use the default value(15s).

func NewLinkerFromEtcd

func NewLinkerFromEtcd(etcdClient *etcd.Client) micro.Linker

NewLinkerFromEtcd creates a etct service linker.

func ServiceNamespace

func ServiceNamespace() string

ServiceNamespace returns the service prefix of ETCD key.

func SetServiceNamespace

func SetServiceNamespace(prefix string)

SetServiceNamespace sets the service prefix of ETCD key. Note: It should be called the first time after importing this package.

Types

type Node

type Node struct {
	Addr string
	Info *ServiceInfo
	// contains filtered or unexported fields
}

Node a service node info.

type Service

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

Service automatically registered api info to etcd

func ServicePlugin

func ServicePlugin(hostport string, etcdConfig etcd.EasyConfig, excludeApis ...string) *Service

ServicePlugin creates a teleport plugin which automatically registered api info to etcd. Note: excludeApis must not be registered to etcd. If etcdConfig.DialTimeout<0, it means unlimit; If etcdConfig.DialTimeout=0, use the default value(15s).

func ServicePluginFromEtcd

func ServicePluginFromEtcd(hostport string, etcdClient *etcd.Client, excludeApis ...string) *Service

ServicePluginFromEtcd creates a teleport plugin which automatically registered api info to etcd. Note: excludeApis must not be registered to etcd.

func (*Service) Etcd

func (s *Service) Etcd() *etcd.Client

Etcd returns the etcd client.

func (*Service) ExcludeApi

func (s *Service) ExcludeApi(excludeApi ...string)

ExcludeApi appends apis that must not be registered to etcd.

func (*Service) Name

func (s *Service) Name() string

Name returns name.

func (*Service) PostListen

func (s *Service) PostListen() error

PostListen adds serviceInfo, and starts etcd keep alive.

func (*Service) PostReg

func (s *Service) PostReg(handler *tp.Handler) error

PostReg registers URI path.

type ServiceInfo

type ServiceInfo struct {
	UriPaths []string `json:"uri_paths"`
	// contains filtered or unexported fields
}

ServiceInfo serivce info

func (*ServiceInfo) Append

func (s *ServiceInfo) Append(uriPath ...string)

Append appends uri path

func (*ServiceInfo) String

func (s *ServiceInfo) String() string

String returns the JSON string.

Jump to

Keyboard shortcuts

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