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 ¶
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) ExcludeApi ¶
ExcludeApi appends apis that must not be registered to etcd.
func (*Service) PostListen ¶
PostListen adds serviceInfo, and starts etcd keep alive.
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