Skip to content

Commit

Permalink
daemon: create pool with a canonical language id
Browse files Browse the repository at this point in the history
Signed-off-by: Denys Smirnov <denys@sourced.tech>
  • Loading branch information
Denys Smirnov authored and dennwc committed May 28, 2019
1 parent caa85f8 commit c128f74
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import (
"sync"
"time"

"github.com/opentracing/opentracing-go"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"

"github.com/bblfsh/bblfshd/daemon/protocol"
"github.com/bblfsh/bblfshd/runtime"

"github.com/bblfsh/sdk/v3/driver/manifest"
protocol2 "github.com/bblfsh/sdk/v3/protocol"
"github.com/opentracing/opentracing-go"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
protocol1 "gopkg.in/bblfsh/sdk.v1/protocol"
)

Expand Down Expand Up @@ -160,12 +162,12 @@ func (d *Daemon) DriverPool(ctx context.Context, language string) (*DriverPool,
return dp, nil
}

image, aliases, err := d.getDriverImage(ctx, language)
image, m, err := d.getDriverImage(ctx, language)
if err != nil {
return nil, ErrRuntime.Wrap(err)
}

return d.newDriverPool(ctx, language, aliases, image)
return d.newDriverPool(ctx, m.Language, m.Aliases, image)
}

func driverWithLang(lang string, list []*runtime.DriverImageStatus) *runtime.DriverImageStatus {
Expand All @@ -184,7 +186,7 @@ func driverWithLang(lang string, list []*runtime.DriverImageStatus) *runtime.Dri
return nil
}

func (d *Daemon) getDriverImage(rctx context.Context, language string) (runtime.DriverImage, []string, error) {
func (d *Daemon) getDriverImage(rctx context.Context, language string) (runtime.DriverImage, *manifest.Manifest, error) {
sp, _ := opentracing.StartSpanFromContext(rctx, "bblfshd.runtime.ListDrivers")
defer sp.Finish()

Expand All @@ -197,7 +199,7 @@ func (d *Daemon) getDriverImage(rctx context.Context, language string) (runtime.
return nil, nil, ErrMissingDriver.New(language)
}
img, err := runtime.NewDriverImage(dr.Reference)
return img, dr.Manifest.Aliases, err
return img, dr.Manifest, err
}

// newDriverPool, instance a new driver pool for the given language and image
Expand Down

0 comments on commit c128f74

Please sign in to comment.