github.com/xmplusdev/xmcore@v1.8.11-0.20240412132628-5518b55526af/features/routing/dispatcher.go (about) 1 package routing 2 3 import ( 4 "context" 5 6 "github.com/xmplusdev/xmcore/common/net" 7 "github.com/xmplusdev/xmcore/features" 8 "github.com/xmplusdev/xmcore/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 }