Documentation ¶
Overview ¶
Package resolver handles name resolution for the Swarm . It implements the Resolver interface as well as clients to connect to external name resolution services.
Index ¶
- Variables
- type Address
- type CloseError
- type ConnectionConfig
- type Interface
- type MultiResolver
- func (mr *MultiResolver) ChainCount(tld string) int
- func (mr *MultiResolver) Close() error
- func (mr *MultiResolver) GetChain(tld string) []Interface
- func (mr *MultiResolver) PopResolver(tld string) error
- func (mr *MultiResolver) PushResolver(tld string, r Interface) error
- func (mr *MultiResolver) Resolve(name string) (Address, 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") )
Functions ¶
This section is empty.
Types ¶
type CloseError ¶
type CloseError struct {
// contains filtered or unexported fields
}
CloseError denotes that at least one resolver in the MultiResolver has had an error when Close was called.
func (CloseError) Error ¶
func (me CloseError) Error() string
Error returns a formatted multi close error.
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 retruns 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) []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 reslover from the name resolution chain for the given TLD. TLD names should be prepended with a dot (eg ".tld"). An empty TLD will pop from the default resolver chain.
func (*MultiResolver) PushResolver ¶
func (mr *MultiResolver) PushResolver(tld string, r Interface) error
PushResolver will push a new Resolver to the name resolution chain for the given TLD. TLD names should be prepended with a dot (eg ".tld"). An empty TLD will push to the default resolver chain.
func (*MultiResolver) Resolve ¶
func (mr *MultiResolver) Resolve(name string) (Address, 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 WithForceDefault ¶
func WithForceDefault() Option
WithForceDefault will force resolution using the default resolver chain.