summaryrefslogtreecommitdiff
path: root/roadrunner/roadrunner.go
diff options
context:
space:
mode:
Diffstat (limited to 'roadrunner/roadrunner.go')
-rw-r--r--roadrunner/roadrunner.go42
1 files changed, 19 insertions, 23 deletions
diff --git a/roadrunner/roadrunner.go b/roadrunner/roadrunner.go
index 34101782..651eb8a2 100644
--- a/roadrunner/roadrunner.go
+++ b/roadrunner/roadrunner.go
@@ -5,7 +5,6 @@ import (
configImpl "github.com/roadrunner-server/config/v2"
endure "github.com/roadrunner-server/endure/pkg/container"
- "github.com/roadrunner-server/errors"
"github.com/roadrunner-server/roadrunner/v2/internal/container"
"github.com/roadrunner-server/roadrunner/v2/internal/meta"
)
@@ -22,11 +21,10 @@ type RR struct {
// NewRR creates a new RR instance that can then be started or stopped by the caller
func NewRR(cfgFile string, override *[]string, pluginList []interface{}) (*RR, error) {
- const op = errors.Op("new_rr")
// create endure container config
containerCfg, err := container.NewConfig(cfgFile)
if err != nil {
- return nil, errors.E(op, err)
+ return nil, err
}
cfg := &configImpl.Plugin{
@@ -40,24 +38,25 @@ func NewRR(cfgFile string, override *[]string, pluginList []interface{}) (*RR, e
// create endure container
endureContainer, err := container.NewContainer(*containerCfg)
if err != nil {
- return nil, errors.E(op, err)
+ return nil, err
}
// register config plugin
- if err = endureContainer.Register(cfg); err != nil {
- return nil, errors.E(op, err)
+ err = endureContainer.Register(cfg)
+ if err != nil {
+ return nil, err
}
// register another container plugins
- for i := 0; i < len(pluginList); i++ {
- if err = endureContainer.Register(pluginList[i]); err != nil {
- return nil, errors.E(op, err)
- }
+ err = endureContainer.RegisterAll(pluginList...)
+ if err != nil {
+ return nil, err
}
// init container and all services
- if err = endureContainer.Init(); err != nil {
- return nil, errors.E(op, err)
+ err = endureContainer.Init()
+ if err != nil {
+ return nil, err
}
rr := &RR{
@@ -72,27 +71,24 @@ func NewRR(cfgFile string, override *[]string, pluginList []interface{}) (*RR, e
// Serve starts RR and starts listening for requests.
// This is a blocking call that will return an error if / when one occurs in a plugin
func (rr *RR) Serve() error {
- const op = errors.Op("rr.serve")
// start serving the graph
errCh, err := rr.container.Serve()
if err != nil {
- return errors.E(op, err)
+ return err
}
- for {
- select {
- case e := <-errCh:
- rr.Stop()
- return fmt.Errorf("error: %w\nplugin: %s", e.Error, e.VertexID)
- }
- }
+ e := <-errCh
+
+ return fmt.Errorf("error: %w\nplugin: %s", e.Error, e.VertexID)
}
// Stop stops roadrunner
func (rr *RR) Stop() error {
- if err := rr.container.Stop(); err != nil {
- return fmt.Errorf("error: %w", err)
+ err := rr.container.Stop()
+ if err != nil {
+ return err
}
+
return nil
}