github.com/xraypb/xray-core@v1.6.6/features/routing/dispatcher.go (about) 1 package routing 2 3 import ( 4 "context" 5 6 "github.com/xraypb/xray-core/common/net" 7 "github.com/xraypb/xray-core/features" 8 "github.com/xraypb/xray-core/transport" 9 ) 10 11 // Dispatcher is a feature that dispatches inbound requests to outbound handlers based on rules. 12 // Dispatcher is required to be registered in a Xray instance to make Xray function properly. 13 // 14 // xray:api:stable 15 type Dispatcher interface { 16 features.Feature 17 18 // Dispatch returns a Ray for transporting data for the given request. 19 Dispatch(ctx context.Context, dest net.Destination) (*transport.Link, error) 20 DispatchLink(ctx context.Context, dest net.Destination, link *transport.Link) error 21 } 22 23 // DispatcherType returns the type of Dispatcher interface. Can be used to implement common.HasType. 24 // 25 // xray:api:stable 26 func DispatcherType() interface{} { 27 return (*Dispatcher)(nil) 28 }