Documentation ¶
Index ¶
- Variables
- type ConnectionConfig
- type MultiResolver
- func (mr *MultiResolver) ChainCount(tld string) int
- func (mr *MultiResolver) Close() error
- func (mr *MultiResolver) GetChain(tld string) []resolver.Interface
- func (mr *MultiResolver) PopResolver(tld string) error
- func (mr *MultiResolver) PushResolver(tld string, r resolver.Interface)
- func (mr *MultiResolver) Resolve(name string) (addr resolver.Address, err error)
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTLDTooLong denotes when a TLD in a name exceeds maximum length. ErrTLDTooLong = fmt.Errorf("TLD exceeds maximum length of %d characters", maxTLDLength) // ErrInvalidTLD denotes passing an invalid TLD to the MultiResolver. ErrInvalidTLD = errors.New("invalid TLD") // ErrResolverChainEmpty denotes trying to pop an empty resolver chain. ErrResolverChainEmpty = errors.New("resolver chain empty") // ErrResolverChainFailed denotes that an entire name resolution chain // for a given TLD failed. ErrResolverChainFailed = errors.New("resolver chain failed") // ErrCloseFailed denotes that closing the multiresolver failed. ErrCloseFailed = errors.New("close failed") )
Functions ¶
This section is empty.
Types ¶
type ConnectionConfig ¶
ConnectionConfig contains the TLD, endpoint and contract address used to establish to a resolver.
func ParseConnectionStrings ¶
func ParseConnectionStrings(cstrs []string) ([]ConnectionConfig, error)
ParseConnectionStrings will apply ParseConnectionString to each connection string. Returns first error found.
type MultiResolver ¶
type MultiResolver struct { // ForceDefault will force all names to be resolved by the default // resolution chain, regadless of their TLD. ForceDefault bool // contains filtered or unexported fields }
MultiResolver performs name resolutions based on the TLD label in the name.
func NewMultiResolver ¶
func NewMultiResolver(opts ...Option) *MultiResolver
NewMultiResolver will return a new MultiResolver instance.
func (*MultiResolver) ChainCount ¶
func (mr *MultiResolver) ChainCount(tld string) int
ChainCount returns the number of resolvers in a resolver chain for the given tld. TLD names should be prepended with a dot (eg ".tld"). An empty TLD will return the number of resolvers in the default resolver chain.
func (*MultiResolver) Close ¶
func (mr *MultiResolver) Close() error
Close all will call Close on all resolvers in all resolver chains.
func (*MultiResolver) GetChain ¶
func (mr *MultiResolver) GetChain(tld string) []resolver.Interface
GetChain will return the resolution chain for a given TLD. TLD names should be prepended with a dot (eg ".tld"). An empty TLD will return all resolvers in the default resolver chain.
func (*MultiResolver) PopResolver ¶
func (mr *MultiResolver) PopResolver(tld string) error
PopResolver will pop the last resolver from the name resolution chain for the given TLD. An empty TLD will pop from the default resolver chain.
func (*MultiResolver) PushResolver ¶
func (mr *MultiResolver) PushResolver(tld string, r resolver.Interface)
PushResolver will push a new Resolver to the name resolution chain for the given TLD. An empty TLD will push to the default resolver chain.
func (*MultiResolver) Resolve ¶
func (mr *MultiResolver) Resolve(name string) (addr resolver.Address, err error)
Resolve will attempt to resolve a name to an address. The resolution chain is selected based on the TLD of the name. If the name does not end in a TLD, the default resolution chain is selected. The resolution will be performed iteratively on the resolution chain, returning the result of the first Resolver that succeeds. If all resolvers in the chain return an error, the function will return an ErrResolveFailed.
type Option ¶
type Option func(*MultiResolver)
Option is a function that applies an option to a MultiResolver.
func WithConnectionConfigs ¶
func WithConnectionConfigs(cfgs []ConnectionConfig) Option
WithConnectionConfigs will set the initial connection configuration.
func WithDefaultCIDResolver ¶
func WithDefaultCIDResolver() Option
func WithForceDefault ¶
func WithForceDefault() Option
WithForceDefault will force resolution using the default resolver chain.
func WithLogger ¶
WithLogger will set the logger used by the MultiResolver.