go-zero/zrpc/internal/resolver/resolver.go

43 lines
813 B
Go
Raw Normal View History

2020-07-30 20:09:45 +08:00
package resolver
2020-08-25 18:36:30 +08:00
import (
"fmt"
"google.golang.org/grpc/resolver"
)
2020-07-30 20:09:45 +08:00
2020-08-06 20:55:38 +08:00
const (
2021-03-02 00:04:12 +08:00
// DirectScheme stands for direct scheme.
2021-03-01 23:52:44 +08:00
DirectScheme = "direct"
2021-03-02 00:04:12 +08:00
// DiscovScheme stands for discov scheme.
2021-03-01 23:52:44 +08:00
DiscovScheme = "discov"
2021-03-02 00:04:12 +08:00
// EndpointSepChar is the separator cha in endpoints.
2020-08-25 18:36:30 +08:00
EndpointSepChar = ','
2021-03-01 23:52:44 +08:00
subsetSize = 32
2020-08-06 20:55:38 +08:00
)
2020-08-18 18:36:44 +08:00
var (
2021-03-02 00:04:12 +08:00
// EndpointSep is the separator string in endpoints.
2020-08-25 18:36:30 +08:00
EndpointSep = fmt.Sprintf("%c", EndpointSepChar)
2021-03-01 23:52:44 +08:00
dirBuilder directBuilder
disBuilder discovBuilder
2020-08-18 18:36:44 +08:00
)
2020-07-31 17:33:08 +08:00
2021-03-02 00:04:12 +08:00
// RegisterResolver registers the direct and discov schemes to the resolver.
2020-08-18 18:36:44 +08:00
func RegisterResolver() {
resolver.Register(&dirBuilder)
resolver.Register(&disBuilder)
2020-07-31 17:33:08 +08:00
}
2020-08-18 18:36:44 +08:00
type nopResolver struct {
2020-08-04 11:59:39 +08:00
cc resolver.ClientConn
2020-07-31 17:33:08 +08:00
}
2020-08-18 18:36:44 +08:00
func (r *nopResolver) Close() {
2020-07-30 20:09:45 +08:00
}
2020-08-18 18:36:44 +08:00
func (r *nopResolver) ResolveNow(options resolver.ResolveNowOptions) {
2020-07-30 20:09:45 +08:00
}