From 9c40ef47ddb3abc429ea32956522801cd46a0980 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Sat, 3 Jun 2023 11:34:29 +0800 Subject: [PATCH] fix: unable to monitor data source status issue --- controllers/data_source.go | 17 +++++++++++++++++ ds/service.go | 3 +++ 2 files changed, 20 insertions(+) diff --git a/controllers/data_source.go b/controllers/data_source.go index 5bcc4f9..ed5252c 100644 --- a/controllers/data_source.go +++ b/controllers/data_source.go @@ -69,6 +69,23 @@ func (ctr *dataSourceController) Post(c *gin.Context) { HandleSuccess(c) } +func (ctr *dataSourceController) Put(c *gin.Context) { + // data source + var _ds models.DataSource + if err := c.ShouldBindJSON(&_ds); err != nil { + HandleErrorBadRequest(c, err) + return + } + + if err := delegate.NewModelDelegate(&_ds).Save(); err != nil { + HandleErrorInternalServerError(c, err) + return + } + + // check data source status + go func() { _ = ctr.ctx.dsSvc.CheckStatus(_ds.Id) }() +} + type dataSourceContext struct { dsSvc interfaces.DataSourceService } diff --git a/ds/service.go b/ds/service.go index dcd6618..f95f57a 100644 --- a/ds/service.go +++ b/ds/service.go @@ -288,6 +288,9 @@ func NewDataSourceService(opts ...DataSourceServiceOption) (svc2 interfaces.Data // initialize svc.Init() + // start + svc.Start() + return svc, nil }