add protocol option for node
This commit is contained in:
11
chain/hop.go
11
chain/hop.go
@ -3,8 +3,9 @@ package chain
|
|||||||
import "context"
|
import "context"
|
||||||
|
|
||||||
type SelectOptions struct {
|
type SelectOptions struct {
|
||||||
Addr string
|
Addr string
|
||||||
Host string
|
Host string
|
||||||
|
Protocol string
|
||||||
}
|
}
|
||||||
|
|
||||||
type SelectOption func(*SelectOptions)
|
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 {
|
type Hop interface {
|
||||||
Nodes() []*Node
|
Nodes() []*Node
|
||||||
Select(ctx context.Context, opts ...SelectOption) *Node
|
Select(ctx context.Context, opts ...SelectOption) *Node
|
||||||
|
@ -15,6 +15,7 @@ type NodeOptions struct {
|
|||||||
HostMapper hosts.HostMapper
|
HostMapper hosts.HostMapper
|
||||||
Metadata metadata.Metadata
|
Metadata metadata.Metadata
|
||||||
Host string
|
Host string
|
||||||
|
Protocol string
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeOption func(*NodeOptions)
|
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 {
|
func MetadataNodeOption(md metadata.Metadata) NodeOption {
|
||||||
return func(o *NodeOptions) {
|
return func(o *NodeOptions) {
|
||||||
o.Metadata = md
|
o.Metadata = md
|
||||||
|
Reference in New Issue
Block a user