Router plugin
This commit is contained in:
31
pkg/plugin/implementation/router/cmd/plugin.go
Normal file
31
pkg/plugin/implementation/router/cmd/plugin.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
definition "github.com/beckn/beckn-onix/pkg/plugin/definition"
|
||||
router "github.com/beckn/beckn-onix/pkg/plugin/implementation/router"
|
||||
)
|
||||
|
||||
// RouterProvider provides instances of Router.
|
||||
type RouterProvider struct{}
|
||||
|
||||
// New initializes a new Router instance.
|
||||
func (rp RouterProvider) New(ctx context.Context, config map[string]string) (definition.Router, func() error, error) {
|
||||
if ctx == nil {
|
||||
return nil, nil, errors.New("context cannot be nil")
|
||||
}
|
||||
|
||||
// Parse the routing_config key from the config map
|
||||
routingConfig, ok := config["routing_config"]
|
||||
if !ok {
|
||||
return nil, nil, errors.New("routing_config is required in the configuration")
|
||||
}
|
||||
return router.New(ctx, &router.Config{
|
||||
RoutingConfig: routingConfig,
|
||||
})
|
||||
}
|
||||
|
||||
// Provider is the exported symbol that the plugin manager will look for.
|
||||
var Provider definition.RouterProvider = RouterProvider{}
|
||||
Reference in New Issue
Block a user