add protocol option for node
This commit is contained in:
@ -5,6 +5,7 @@ import "context"
|
||||
type SelectOptions struct {
|
||||
Addr string
|
||||
Host string
|
||||
Protocol string
|
||||
}
|
||||
|
||||
type SelectOption func(*SelectOptions)
|
||||
@ -21,6 +22,12 @@ func HostSelectOption(host string) SelectOption {
|
||||
}
|
||||
}
|
||||
|
||||
func ProtocolSelectOption(protocol string) SelectOption {
|
||||
return func(o *SelectOptions) {
|
||||
o.Protocol = protocol
|
||||
}
|
||||
}
|
||||
|
||||
type Hop interface {
|
||||
Nodes() []*Node
|
||||
Select(ctx context.Context, opts ...SelectOption) *Node
|
||||
|
@ -15,6 +15,7 @@ type NodeOptions struct {
|
||||
HostMapper hosts.HostMapper
|
||||
Metadata metadata.Metadata
|
||||
Host string
|
||||
Protocol string
|
||||
}
|
||||
|
||||
type NodeOption func(*NodeOptions)
|
||||
@ -49,6 +50,12 @@ func HostNodeOption(host string) NodeOption {
|
||||
}
|
||||
}
|
||||
|
||||
func ProtocolNodeOption(protocol string) NodeOption {
|
||||
return func(o *NodeOptions) {
|
||||
o.Protocol = protocol
|
||||
}
|
||||
}
|
||||
|
||||
func MetadataNodeOption(md metadata.Metadata) NodeOption {
|
||||
return func(o *NodeOptions) {
|
||||
o.Metadata = md
|
||||
|
Reference in New Issue
Block a user