Documentation ¶
Overview ¶
Copyright 2020 duyanghao
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. Package endpoint resolves etcd entpoints using grpc targets of the form 'endpoint://<id>/<endpoint>'.
Index ¶
- func Dialer(ctx context.Context, dialEp string) (net.Conn, error)
- func IsTarget(target string) bool
- func ParseEndpoint(endpoint string) (proto string, host string, scheme string)
- func ParseTarget(target string) (string, string, error)
- func Target(id, endpoint string) string
- type Resolver
- type ResolverGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dialer ¶
Dialer dials a endpoint using net.Dialer. Context cancelation and timeout are supported.
func ParseEndpoint ¶
ParseEndpoint endpoint parses an endpoint of the form (http|https)://<host>*|(unix|unixs)://<path>) and returns a protocol ('tcp' or 'unix'), host (or filepath if a unix socket), scheme (http, https, unix, unixs).
func ParseTarget ¶
ParseTarget parses a endpoint://<id>/<endpoint> string and returns the parsed id and endpoint. If the target is malformed, an error is returned.
Types ¶
type Resolver ¶
Resolver provides a resolver for a single etcd cluster, identified by name.
func (*Resolver) ResolveNow ¶
func (*Resolver) ResolveNow(o resolver.ResolveNowOption)
type ResolverGroup ¶
type ResolverGroup struct {
// contains filtered or unexported fields
}
ResolverGroup keeps all endpoints of resolvers using a common endpoint://<id>/ target up-to-date.
func NewResolverGroup ¶
func NewResolverGroup(id string) (*ResolverGroup, error)
NewResolverGroup creates a new ResolverGroup with the given id.
func (*ResolverGroup) Close ¶
func (e *ResolverGroup) Close()
func (*ResolverGroup) SetEndpoints ¶
func (e *ResolverGroup) SetEndpoints(endpoints []string)
SetEndpoints updates the endpoints for ResolverGroup. All registered resolver are updated immediately with the new endpoints.
func (*ResolverGroup) Target ¶
func (e *ResolverGroup) Target(endpoint string) string
Target constructs a endpoint target using the endpoint id of the ResolverGroup.