diff --git a/pkg/athena/routes/routes.go b/pkg/athena/routes/routes.go index 86161420..4a642d53 100644 --- a/pkg/athena/routes/routes.go +++ b/pkg/athena/routes/routes.go @@ -40,7 +40,7 @@ func (r *AthenaResourceHandler) workgroups(rw http.ResponseWriter, req *http.Req routes.SendResources(rw, res, err) } -func (r *(AthenaResourceHandler)) workgroupEngineVersion(rw http.ResponseWriter, req *http.Request) { +func (r *AthenaResourceHandler) workgroupEngineVersion(rw http.ResponseWriter, req *http.Request) { reqBody, err := routes.ParseBody(req.Body) if err != nil { rw.WriteHeader(http.StatusBadRequest) diff --git a/pkg/main.go b/pkg/main.go index dff35c2f..aa3f28f4 100644 --- a/pkg/main.go +++ b/pkg/main.go @@ -1,6 +1,9 @@ package main import ( + "context" + "github.com/grafana/grafana-plugin-sdk-go/backend" + "github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt" "os" "github.com/grafana/athena-datasource/pkg/athena" @@ -12,18 +15,24 @@ import ( func main() { // Start listening to requests sent from Grafana. - s := athena.New() - ds := awsds.NewAsyncAWSDatasource(s) - ds.Completable = s - ds.EnableMultipleConnections = true - ds.CustomRoutes = routes.New(s).Routes() - if err := datasource.Manage( "grafana-athena-datasource", - ds.NewDatasource, + MakeDatasourceFactory(), datasource.ManageOpts{}, ); err != nil { log.DefaultLogger.Error(err.Error()) os.Exit(1) } } + +func MakeDatasourceFactory() datasource.InstanceFactoryFunc { + return func(ctx context.Context, settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) { + log.DefaultLogger.FromContext(ctx).Debug("building new datasource instance") + s := athena.New() + ds := awsds.NewAsyncAWSDatasource(s) + ds.Completable = s + ds.EnableMultipleConnections = true + ds.CustomRoutes = routes.New(s).Routes() + return ds.NewDatasource(ctx, settings) + } +}