diff --git a/internal/hummingbird/core/application/deviceapp/deviceaction.go b/internal/hummingbird/core/application/deviceapp/deviceaction.go index 60e5b9e..3a56f27 100644 --- a/internal/hummingbird/core/application/deviceapp/deviceaction.go +++ b/internal/hummingbird/core/application/deviceapp/deviceaction.go @@ -29,11 +29,6 @@ import ( "time" ) -const ( - ResultSuccess = "success" - ResultFail = "fail" -) - // ui控制台、定时任务、场景联动、云平台api 都可以调用 func (p *deviceApp) DeviceAction(jobAction dtos.JobAction) dtos.DeviceExecRes { defer func() { @@ -137,11 +132,6 @@ func (p *deviceApp) SetDeviceProperty(req dtos.OpenApiSetDeviceThingModel) error if err != nil { return err } - //var findCode bool - // - //for _, property := range product.Properties { - // if property.Code - //} deviceService, err := p.dbClient.DeviceServiceById(device.DriveInstanceId) if err != nil { diff --git a/internal/hummingbird/core/application/driverapp/driverlib.go b/internal/hummingbird/core/application/driverapp/driverlib.go index 462eee9..380a26a 100644 --- a/internal/hummingbird/core/application/driverapp/driverlib.go +++ b/internal/hummingbird/core/application/driverapp/driverlib.go @@ -138,17 +138,6 @@ func (app *driverLibApp) DeleteDeviceLibraryById(ctx context.Context, id string) return errort.NewCommonErr(errort.DeviceLibraryMustDeleteDeviceService, fmt.Errorf("must delete service")) } - // 删除驱动前需要查看 驱动所属的产品是否存在 - //_, total, edgeXErr = app.dbClient.ProductsSearch(0, 1, dtos.ProductSearchQueryRequest{ - // DeviceLibraryId: id, - //}) - //if edgeXErr != nil { - // return edgeXErr - //} - //if total > 0 { - // return errort.NewCommonErr(errort.DeviceLibraryMustDeleteProduct, fmt.Errorf("must delete product")) - //} - app.manager.Remove(id) return nil diff --git a/internal/hummingbird/core/application/driverapp/manage.go b/internal/hummingbird/core/application/driverapp/manage.go index 8d26185..6185eb4 100644 --- a/internal/hummingbird/core/application/driverapp/manage.go +++ b/internal/hummingbird/core/application/driverapp/manage.go @@ -173,12 +173,6 @@ func getNewSupportVersion(versions models.SupportVersions, curVersion, newVersio } func (m *deviceLibraryManager) updateDLDefaultVersion(dl models.DeviceLibrary, newVersion models.SupportVersion) models.DeviceLibrary { - // 2.驱动库配置更新为新版本的 - //dl.Config = newVersion.ConfigJson - //if dl.Config == "" { - // dl.Config = dtos.GetLibrarySimpleBaseConfig() - //} - //dl.ConfigFile = newVersion.ConfigFile dl.Version = newVersion.Version return dl } diff --git a/internal/hummingbird/core/application/driverserviceapp/servicemanager.go b/internal/hummingbird/core/application/driverserviceapp/servicemanager.go index 24f1525..f5bc36c 100644 --- a/internal/hummingbird/core/application/driverserviceapp/servicemanager.go +++ b/internal/hummingbird/core/application/driverserviceapp/servicemanager.go @@ -18,7 +18,6 @@ import ( "github.com/winc-link/hummingbird/internal/pkg/utils" "gorm.io/gorm" "net" - "reflect" "strconv" "strings" @@ -316,15 +315,6 @@ func (m *driverServiceAppM) Del(ctx context.Context, id string) error { return edgeXErr } - // 删除驱动实例前需要查看 实例所属的设备是否存在 - //_, total, edgeXErr := m.getDeviceApp().DevicesSearch(dtos.DeviceSearchQueryRequest{ServiceId: id}) - //if edgeXErr != nil { - // return edgeXErr - //} - //if total > 0 { - // return errort.NewCommonErr(errort.DeviceServiceMustDeleteDevice, fmt.Errorf("must delete device")) - //} - // 检查容器是否在运行中 if m.GetState(id) != constants.RunStatusStopped { return errort.NewCommonErr(errort.DeviceServiceMustStopService, fmt.Errorf("must stop service")) @@ -398,37 +388,6 @@ func (m *driverServiceAppM) initMonitor() { } } -// -//func (m *driverServiceAppM) UpdateAdvanceConfig(ctx context.Context, req dtos.UpdateServiceLogLevelConfigRequest) error { -// ds, err := m.Get(ctx, req.Id) -// if err != nil { -// return err -// } -// -// // 更新配置 -// ds.LogLevel = constants.LogLevel(req.LogLevel) -// -// if err = m.dbClient.UpdateDeviceService(ds); err != nil { -// return err -// } -// -// // 通知驱动 -// if !ds.IsRunning() { -// m.lc.Infof("service %s is stop", ds.Id) -// return nil -// } -// if ds.IsDriver() { -// if err = application.DeviceServiceChangeLogLevelCallback(m.ctx, m.dic, ds, m.lc); err != nil { -// return err -// } -// } else { -// if err = application.AppServiceChangeLogLevelCallback(m.ctx, m.dic, ds, m.lc); err != nil { -// return err -// } -// } -// return nil -//} -// func (m *driverServiceAppM) UpdateRunStatus(ctx context.Context, req dtos.UpdateDeviceServiceRunStatusRequest) error { // 1.正在处理中,返回错误 if m.InProgress(req.Id) { @@ -486,19 +445,6 @@ func (m *driverServiceAppM) buildDriverCfg(localDefaultIp string, runPort int, d data.Address = strings.Split(data.Address, ":")[0] + ":" + strings.Split(sysConfig.RpcServer.Address, ":")[1] configuration.Clients[k] = data } - //else if k == "MQTTBroker" { - // driverMqttInfo, err := m.dbClient.DriverMqttAuthInfo(ds.Id) - // if err != nil { - // return "", err - // } - // data := v - // data.Address = strings.Replace(data.Address, "127.0.0.1", localDefaultIp, -1) - // data.Address = strings.Split(data.Address, ":")[0] + ":" + strings.Split(data.Address, ":")[1] + ":" + "21883" - // data.ClientId = driverMqttInfo.ClientId - // data.Username = driverMqttInfo.UserName - // data.Password = driverMqttInfo.Password - // configuration.Clients[k] = data - //} } configuration.Service.ID = ds.Id @@ -523,308 +469,3 @@ func (m *driverServiceAppM) buildDriverCfg(localDefaultIp string, runPort int, d return buff.String(), nil } - -// -////func (m *driverServiceAppM) buildAppCfg(localDefaultIp string, runPort int, ds models.DeviceService) (string, error) { -//// configuration := &dtos.AppServiceConfig{} -//// sysConfig := container.ConfigurationFrom(m.dic.Get) -//// -//// // 读取模版配置 -//// if _, err := toml.Decode(getDriverConfigTemplate(ds), configuration); err != nil { -//// return "", err -//// } -//// -//// // 修改与核心服务通信的ip -//// p, err := strconv.Atoi(strings.Split(sysConfig.RpcServer.Address, ":")[1]) -//// if err != nil { -//// return "", err -//// } -//// configuration.Tedge.Host = localDefaultIp -//// configuration.Tedge.Port = int32(p) -//// -//// configuration.Server.ID = ds.Id -//// configuration.Server.Name = ds.Name -//// // 驱动服务只开启rpc服务 -//// configuration.Server.Host = "0.0.0.0" -//// configuration.Server.Port = int32(runPort) -//// -//// dl, err := m.getDriverApp().DriverLibById(ds.DeviceLibraryId) -//// if err != nil { -//// return "", err -//// } -//// dlc, err := dl.GetConfig() -//// if err != nil { -//// return "", err -//// } -//// -//// // 如果有专家模式,直接用专家模式的yaml转换为toml,不会有小数点问题 -//// if ds.ExpertMode && ds.ExpertModeContent != "" { -//// err := yaml.Unmarshal([]byte(ds.ExpertModeContent), &configuration.CustomConfig) -//// if err != nil { -//// return "", err -//// } -//// } else { -//// // driver 模块做映射, driver通过配置文件进行强制转换 -//// if ds.Config != nil { -//// if driver, ok := ds.Config[constants.ConfigKeyDriver]; ok { -//// finalDriver := make(map[string]interface{}) -//// if _, ok := driver.(map[string]interface{}); ok { -//// for i, v := range driver.(map[string]interface{}) { -//// v = convertCfgDriverKeyType(dlc, i, v) -//// finalDriver[i] = v -//// } -//// configuration.CustomConfig = finalDriver -//// } -//// } -//// } -//// } -//// -//// // set log level -//// configuration.Log.LogLevel = constants.LogMap[ds.LogLevel] -//// -//// var buff bytes.Buffer -//// e := toml.NewEncoder(&buff) -//// err = e.Encode(configuration) -//// if err != nil { -//// return "", err -//// } -//// -//// return buff.String(), nil -////} -// -//// TODO 只针对docker版本 -////func (m *driverServiceAppM) NotifyAddDevice(d models.Device) { -//// // 目前只支持modbus-rtu协议 -//// protocolKey := constants.DriverModbusRtu -//// if _, ok := d.Protocols[protocolKey]["Address"]; !ok { -//// return -//// } -//// -//// // 如果容器没有处于运行状态,不做任何处理 -//// if m.GetState(d.ServiceId) != constants.RunStatusStarted { -//// return -//// } -//// -//// // 重启docker驱动 -//// err := m.ReStart(d.ServiceId) -//// if err != nil { -//// m.lc.Errorf("NotifyAddDevice restart serviceId(%s) err:%v", d.ServiceId, err) -//// } -////} -// -// 将配置数据强制转换为定义的类型,如果定义错误,则不转换 -func convertCfgDriverKeyType(dlc models.DeviceLibraryConfig, key string, value interface{}) interface{} { - var ok bool - if _, ok = dlc.DeviceServer[constants.ConfigKeyDriver]; !ok { - return value - } - rt := reflect.TypeOf(value) - rv := reflect.ValueOf(value) - items := dlc.DeviceServer[constants.ConfigKeyDriver] - for _, v := range items { - if v.Name == key { - switch v.Type { - case constants.DriverConfigTypeInt: - if rt.Kind() == reflect.String { - tmpV, e := strconv.Atoi(rv.String()) - if e != nil { - return value - } - return tmpV - } - if rt.Kind() == reflect.Float64 { - return int(rv.Float()) - } - return value - case constants.DriverConfigTypeFloat: - if rt.Kind() == reflect.String { - tmpV, e := strconv.ParseInt(rv.String(), 10, 64) - if e != nil { - return value - } - return tmpV - } - if rt.Kind() == reflect.Int { - return float64(rv.Int()) - } - return value - default: - // 其他类型目前先不做处理 - return value - } - } - } - return value -} - -// -//// 清理所有驱动资源:包括驱动镜像、 -//func (m *driverServiceAppM) ClearAllContainer() { -// dss, err := m.AllService() -// if err != nil { -// m.lc.Errorf("get all service err:%v", err) -// return -// } -// for _, v := range dss { -// // 停止驱动 -// _ = m.appModel.StopInstance(dtos.DeviceServiceFromModel(v)) -// } -// -// // 删除驱动路径 /var/tedge/edgex-driver-data -// err = utils.RemoveFileOrDir(constants.DriverBaseDir) -// if err != nil { -// m.lc.Errorf("remove driverBaseDir(%s) err:%v", constants.DriverBaseDir, err) -// } -//} -// -//func (m *driverServiceAppM) AllService() ([]models.DeviceService, error) { -// dss, _, err := m.dbClient.DeviceServicesSearch(0, -1, dtos.DeviceServiceSearchQueryRequest{}) -// return dss, err -//} -// -//func (m *driverServiceAppM) FlushStatsToAgent() { -// // 取出所有驱动,进行批量更新 -// dss, _, edgeXErr := m.Search(context.Background(), dtos.DeviceServiceSearchQueryRequest{}) -// if edgeXErr != nil { -// m.lc.Errorf("deviceServicesSearch err %v", edgeXErr) -// return -// } -// -// // 取出所有缓存 -// client := pkgcontainer.AgentClientNameFrom(m.dic.Get) -// ctx := context.Background() -// stats, err := client.GetAllDriverMonitor(ctx) -// if err != nil { -// m.lc.Errorf("http request get all driver monitor err: %v", err) -// return -// } -// statsIdMap := make(map[string]models.ServiceStats) -// for _, v := range stats { -// // 只处理驱动的服务 -// if v.ServiceType == models.ServiceTypeEnumDriver { -// statsIdMap[v.Id] = dtos.FromDTOServiceStatsToModel(v) -// } -// } -// deleteIds := make([]string, 0) -// -// // 对比获取需要删除的id -// for statsId, _ := range statsIdMap { -// deleteId := statsId -// for _, ds := range dss { -// if ds.Id == statsId { -// deleteId = "" -// } -// } -// if deleteId != "" { -// deleteIds = append(deleteIds, statsId) -// } -// } -// -// // 处理添加/更新 -// for _, v := range dss { -// newStats := models.ServiceStats{} -// if _, ok := statsIdMap[v.Id]; ok { -// newStats = statsIdMap[v.Id] -// } -// newStats.Id = v.Id -// newStats.Name = v.Name -// newStats.LogPath = m.appModel.GetInstanceLogPath(dtos.DeviceServiceFromModel(v)) -// newStats.ServiceType = models.ServiceTypeEnumDriver -// err = client.AddServiceMonitor(ctx, dtos.FromModelsServiceStatsToDTO(newStats)) -// if err != nil { -// m.lc.Errorf("http request add service monitor err: %v", err) -// } -// } -// //处理删除 -// for _, v := range deleteIds { -// err = client.DeleteServiceMonitor(ctx, statsIdMap[v].Id) -// if err != nil { -// m.lc.Errorf("http request delete service monitor err: %v", err) -// } -// } -//} -// -//// 异步调用,自动绑定设备、产品、驱动的关系 -//func (m *driverServiceAppM) autoAddDevice(ds models.DeviceService) { -// // app模型的不作处理 -// if ds.DriverType == constants.DriverLibTypeAppService { -// return -// } -// products, _, err := container.ProductItfFrom(m.dic.Get).ProductsSearch(dtos.ProductSearchQueryRequest{DeviceLibraryId: ds.DeviceLibraryId}) -// if err != nil { -// m.lc.Errorf("search product err: %v", err) -// return -// } -// for _, p := range products { -// m.getProductApp().ProductSyncUpdateDeviceServiceId(p) -// } -//} -// -//// 挂载的设备, 目前只支持modbus-rtu这个配置的设备挂载 -//func buildMountDevices(devices []models.Device) []string { -// mountDevices := make([]string, 0) -// for _, v := range devices { -// if address, ok := v.Protocols[constants.DriverModbusRtu]["Address"]; ok { -// mountDevices = append(mountDevices, address) -// } -// } -// return mountDevices -//} -// -//func AtopReportDriverConfigEdit(dic *di.Container, dl models.DeviceLibrary, ds models.DeviceService, lc logger.LoggingClient) { -// if !application.CanRequestAtop(dic) { -// return -// } -// -// if dl.IsInternal && dl.DriverType == constants.DriverLibTypeDefault { -// runConfig, _ := json.Marshal(ds.Config) -// err := application.AtopDataReport(constants.DataType_ConfigUpdate, dtos.AtopDataReportDriverConfigUpdate{ -// DriverCode: ds.DeviceLibraryId, -// OpenDockerEnv: ds.DockerParamsSwitch, -// DockerEnv: ds.DockerParams, -// OpenExpertMode: ds.ExpertMode, -// ExpertMode: ds.ExpertModeContent, -// RunConfig: string(runConfig), -// }) -// if err != nil { -// lc.Warnf("reportDriverConfigEdit err: %v", err) -// } -// } -// lc.Infof("atopReportDriverConfigEdit success dlId(%v)", dl.Id) -//} -// -//func AtopReportDriverRunOrStop(dic *di.Container, dl models.DeviceLibrary, status int, lc logger.LoggingClient) { -// if !application.CanRequestAtop(dic) { -// return -// } -// -// if dl.IsInternal && dl.DriverType == constants.DriverLibTypeDefault { -// // 不上报 停止中、启动中 这种中间状态,不好控制 -// err := application.AtopDataReport(constants.DataType_DriverRunOrStop, dtos.AtopDataReportDriverRunOrStop{ -// DriverCode: dl.Id, -// RunStatus: status, -// }) -// if err != nil { -// lc.Errorf("reportDriverRunOrStop dlId(%v) err: %v", dl.Id, err) -// return -// } -// } -// lc.Infof("reportDriverRunOrStop success dlId(%v)", dl.Id) -//} -// -//func AtopReportDriverDelete(dic *di.Container, dl models.DeviceLibrary, lc logger.LoggingClient) { -// if !application.CanRequestAtop(dic) { -// return -// } -// -// if dl.IsInternal && dl.DriverType == constants.DriverLibTypeDefault { -// err := application.AtopDataReport(constants.DataType_DriverDelete, dtos.AtopDataReportDriverDelete{ -// DriverCode: dl.Id, -// }) -// if err != nil { -// lc.Errorf("reportDriverDelete dlId(%v) err: %v", dl.Id, err) -// return -// } -// } -// lc.Infof("reportDriverDelete success dlId(%v)", dl.Id) -//} diff --git a/internal/hummingbird/core/application/limit.go b/internal/hummingbird/core/application/limit.go index 2eef67f..74d68b0 100644 --- a/internal/hummingbird/core/application/limit.go +++ b/internal/hummingbird/core/application/limit.go @@ -11,7 +11,6 @@ type LimitMethodConf struct { methods map[string]struct{} } -//TODO: 接口限流功能需要重构 func NewLimitMethodConf(configuration config.ConfigurationStruct) limit.LimitMethodConf { var conf = &LimitMethodConf{methods: make(map[string]struct{})} for _, method := range configuration.Writable.LimitMethods { diff --git a/internal/hummingbird/core/application/timerapp/timerapp.go b/internal/hummingbird/core/application/timerapp/timerapp.go index 1198788..08f6d40 100644 --- a/internal/hummingbird/core/application/timerapp/timerapp.go +++ b/internal/hummingbird/core/application/timerapp/timerapp.go @@ -180,10 +180,7 @@ func (et *EdgeTimer) run() { timer.Stop() now = now.In(et.location) et.logger.Infof("wake now: %+v with jobID: %s", now, et.entries[0].JobID) - var ( - //finished []int - //eIndex = len(et.entries) - 1 - ) + var () for i, e := range et.entries { if e.Next.After(now) || e.Next.IsZero() { break @@ -200,32 +197,11 @@ func (et *EdgeTimer) run() { if next, b := e.Schedule.Next(now); !b { e.Next = next et.logger.Infof("run now: %+v, entry: jobId: %s, jobName: %s, next: %+v", now, e.JobID, e.Schedule.JobName, e.Next) - // update prev next and runtimes - //if err := et.db.UpdateRuntimeInfo(e.JobID, e.Prev.UnixMilli(), e.Next.UnixMilli(), times); err != nil { - // et.logger.Errorf("update job: %s runtime info error: %s, prev: %d, next: %d", - // e.JobID, err, e.Prev.Unix(), e.Next.Unix()) - //} } //} } } - //if len(finished) > 0 { - // for i := range finished { - // et.entries[finished[i]], et.entries[eIndex] = et.entries[eIndex], et.entries[finished[i]] - // eIndex-- - // } - // del := et.entries[eIndex+1:] - // ids := make([]string, 0, len(del)) - // for i := range del { - // ids = append(ids, del[i].JobID) - // } - // et.logger.Infof("jobs ended, delete from db: %+v", ids) - // if err := et.db.DeleteJobs(ids); err != nil { - // et.logger.Errorf("jobs ended, delete from db failure: %+v", ids) - // } - // et.entries = et.entries[:eIndex+1] - //} - //et.logger.Infof("entries len: %d", len(et.entries)) + case newEntry := <-et.add: timer.Stop() now = et.now() @@ -299,14 +275,6 @@ func (et *EdgeTimer) AddJobToRunQueue(j *jobs.JobSchedule) error { et.logger.Warnf("job is already in map: %s", j.JobID) return nil } - // check expire - //if exp, ok := j.TimeData.Expression.(jobs.CronExp); !ok { - // return errort.NewCommonErr(errort.DefaultSystemError, fmt.Errorf("cron job expression error")) - //} else { - // if _, err := jobs.ParseStandard(exp.CronTab); err != nil { - // return err - // } - //} if _, err := jobs.ParseStandard(j.TimeData.Expression); err != nil { return err diff --git a/internal/hummingbird/core/container/agentitf.go b/internal/hummingbird/core/container/agentitf.go deleted file mode 100644 index 92b9571..0000000 --- a/internal/hummingbird/core/container/agentitf.go +++ /dev/null @@ -1 +0,0 @@ -package container diff --git a/internal/hummingbird/core/container/systemitf.go b/internal/hummingbird/core/container/systemitf.go deleted file mode 100644 index bec1fc1..0000000 --- a/internal/hummingbird/core/container/systemitf.go +++ /dev/null @@ -1,16 +0,0 @@ -package container - -import ( - //"gitlab.com/tedge/edgex/internal/pkg/di" - //"gitlab.com/tedge/edgex/internal/tedge/resource/interfaces" - interfaces "github.com/winc-link/hummingbird/internal/hummingbird/core/interface" - "github.com/winc-link/hummingbird/internal/pkg/di" -) - -// SystemItfName -var SystemItfName = di.TypeInstanceToName((*interfaces.SystemItf)(nil)) - -// SystemItfFrom -func SystemItfFrom(get di.Get) interfaces.SystemItf { - return get(SystemItfName).(interfaces.SystemItf) -} diff --git a/internal/hummingbird/core/controller/http/gateway/cloudinstance.go b/internal/hummingbird/core/controller/http/gateway/cloudinstance.go deleted file mode 100644 index de955f3..0000000 --- a/internal/hummingbird/core/controller/http/gateway/cloudinstance.go +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * Copyright 2017 Dell Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - *******************************************************************************/ - -package gateway - -import ( - "github.com/gin-gonic/gin" - "github.com/winc-link/hummingbird/internal/pkg/httphelper" -) - -// @Tags 我的云服务实例 -// @Summary 云服务实例列表 -// @Produce json -// @Param request query dtos.CloudInstanceSearchQueryRequest true "参数" -// @Success 200 {object} dtos.CloudInstanceSearchQueryRequest -// @Router /api/v1/cloud-instance [get] -//@Security ApiKeyAuth -func (ctl *controller) CloudInstanceSearch(c *gin.Context) { - lc := ctl.lc - //var req dtos.CloudInstanceSearchQueryRequest - //urlDecodeParam(&req, c.Request, lc) - //dtos.CorrectionPageParam(&req.BaseSearchConditionQuery) - //data, total := 1,0 - data := make([]string, 0) - total := 0 - pageResult := httphelper.NewPageResult(data, uint32(total), 1, 10) - httphelper.ResultSuccess(pageResult, c.Writer, lc) -} diff --git a/internal/hummingbird/core/controller/http/gateway/controller.go b/internal/hummingbird/core/controller/http/gateway/controller.go index 705ade5..85df433 100644 --- a/internal/hummingbird/core/controller/http/gateway/controller.go +++ b/internal/hummingbird/core/controller/http/gateway/controller.go @@ -99,10 +99,6 @@ func (ctl *controller) getHomePageApp() interfaces.HomePageItf { return container.HomePageAppNameFrom(ctl.dic.Get) } -func (ctl *controller) getSystemApp() interfaces.SystemItf { - return container.SystemItfFrom(ctl.dic.Get) -} - func (ctl *controller) getDocsApp() interfaces.DocsApp { return container.DocsTemplateAppFrom(ctl.dic.Get) } diff --git a/internal/hummingbird/core/initialize/init.go b/internal/hummingbird/core/initialize/init.go index 8d03ad3..5ec1024 100644 --- a/internal/hummingbird/core/initialize/init.go +++ b/internal/hummingbird/core/initialize/init.go @@ -303,20 +303,6 @@ func (b *Bootstrap) initClient(ctx context.Context, wg *sync.WaitGroup, dic *di. }, }) - //agentApp := agentclient.New(configuration.Clients["Agent"].Address()) - //dic.Update(di.ServiceConstructorMap{ - // container.AgentClientName: func(get di.Get) interface{} { - // return agentApp - // }, - //}) - // - //cacheClient := localcache.NewRamCacheClient() - //dic.Update(di.ServiceConstructorMap{ - // pkgContainer.CacheFuncName: func(get di.Get) interface{} { - // return cacheClient - // }, - //}) - persistItf := persistence.NewPersistApp(dic) dic.Update(di.ServiceConstructorMap{ container.PersistItfName: func(get di.Get) interface{} { diff --git a/internal/hummingbird/core/interface/system.go b/internal/hummingbird/core/interface/system.go deleted file mode 100644 index 2e3bc4f..0000000 --- a/internal/hummingbird/core/interface/system.go +++ /dev/null @@ -1,11 +0,0 @@ -package interfaces - -type SystemItf interface { - //GwConfigItf - //NetworkItf - //GatewayItf -} - -//type GatewayItf interface { -// -//} diff --git a/internal/hummingbird/core/migrates/migrate.go b/internal/hummingbird/core/migrates/migrate.go deleted file mode 100644 index 15fddaa..0000000 --- a/internal/hummingbird/core/migrates/migrate.go +++ /dev/null @@ -1,33 +0,0 @@ -package migrates - -import ( - "github.com/go-gormigrate/gormigrate/v2" - _ "github.com/jinzhu/gorm/dialects/sqlite" - "github.com/winc-link/hummingbird/internal/pkg/container" - "github.com/winc-link/hummingbird/internal/pkg/di" - - bootstrapContainer "github.com/winc-link/hummingbird/internal/hummingbird/core/container" -) - -func Migrate(dic *di.Container) { - dbClient := bootstrapContainer.DBClientFrom(dic.Get) - lc := container.LoggingClientFrom(dic.Get) - m := gormigrate.New(dbClient.GetDBInstance(), gormigrate.DefaultOptions, migrations()) - - if err := m.Migrate(); err != nil { - lc.Errorf("Migration run err: %v", err) - } else { - lc.Info("Migration run successfully") - } -} - -func migrations() []*gormigrate.Migration { - return []*gormigrate.Migration{ - //m_1627356992_funcpoint_properties(), - //m_1630660539_device_expand_data(), - //m_1630660539_update_screen_device(), - //m_1637287851_update_library_internal(), - //m_1641866282_upgrade_cloud_market(), - //m_1648619146_upgrade_driver_app(), - } -} diff --git a/internal/hummingbird/core/route/gateway.go b/internal/hummingbird/core/route/gateway.go index c654b9d..e03a6b3 100644 --- a/internal/hummingbird/core/route/gateway.go +++ b/internal/hummingbird/core/route/gateway.go @@ -46,15 +46,10 @@ func RegisterGateway(engine *gin.Engine, dic *di.Container) { v1Auth.GET("home-page", ctl.HomePage) } { - /******* 运维管理-agentclient *******/ + /******* 运维监控 *******/ v1Auth.GET("/metrics/system", ctl.SystemMetricsHandler) } - /*******云服实例*******/ - { - v1Auth.GET("cloud-instance", ctl.CloudInstanceSearch) - } - /******* 镜像仓库管理 *******/ { v1Auth.POST("docker-configs", ctl.DockerConfigAdd) @@ -100,10 +95,9 @@ func RegisterGateway(engine *gin.Engine, dic *di.Container) { v1Auth.PUT("thingmodel", ctl.ThingModelUpdate) v1Auth.DELETE("thingmodel", ctl.ThingModelDelete) v1Auth.GET("thingmodel/unit", ctl.ThingModelUnit) - v1Auth.POST("thingmodel/unit-sync", ctl.ThingModelUnitSync) - v1Auth.POST("thingmodel/docs-sync", ctl.ThingModelDocsSync) - v1Auth.POST("thingmodel/quicknavigation-sync", ctl.ThingModelQuickNavigationSync) - //v1Auth.POST("thingmodel/msg-gather", ctl.MsgGather) + v1Auth.POST("thingmodel/unit-sync", ctl.ThingModelUnitSync) //废弃 + v1Auth.POST("thingmodel/docs-sync", ctl.ThingModelDocsSync) //废弃 + v1Auth.POST("thingmodel/quicknavigation-sync", ctl.ThingModelQuickNavigationSync) //废弃 } @@ -133,10 +127,10 @@ func RegisterGateway(engine *gin.Engine, dic *di.Container) { /*******品类、物模型同步接口 *******/ { v1Auth.GET("category-template", ctl.CategoryTemplateSearch) - v1Auth.POST("category-template/sync", ctl.CategoryTemplateSync) + v1Auth.POST("category-template/sync", ctl.CategoryTemplateSync) //废弃 v1Auth.GET("thingmodel-template", ctl.ThingModelTemplateSearch) v1Auth.GET("thingmodel-template/:categoryKey", ctl.ThingModelTemplateByCategoryKey) - v1Auth.POST("thingmodel-template/sync", ctl.ThingModelTemplateSync) + v1Auth.POST("thingmodel-template/sync", ctl.ThingModelTemplateSync) //废弃 } /*******告警中心接口 *******/ @@ -195,7 +189,7 @@ func RegisterGateway(engine *gin.Engine, dic *di.Container) { { v1Auth.GET("language-sdk", ctl.LanguageSdkSearch) - v1Auth.POST("language-sdk-sync", ctl.LanguageSdkSync) + v1Auth.POST("language-sdk-sync", ctl.LanguageSdkSync) //废弃 } } diff --git a/internal/hummingbird/core/route/webproxy.go b/internal/hummingbird/core/route/webproxy.go index fe8b5d2..b1c8470 100644 --- a/internal/hummingbird/core/route/webproxy.go +++ b/internal/hummingbird/core/route/webproxy.go @@ -12,13 +12,12 @@ import ( "strconv" "sync" "time" - + "github.com/gin-gonic/gin" ) ///var/bin/cmd/hummingbird-ui/build const WebBuildPath = "./cmd/hummingbird-ui/build" -const WebBuildPath2 = "/var/build" // WebBootstrap contains references to dependencies required by the BootstrapHandler. type WebBootstrap struct { @@ -40,12 +39,12 @@ func NewWebBootstrap() *WebBootstrap { func (b *WebBootstrap) BootstrapHandler(ctx context.Context, wg *sync.WaitGroup, _ startup.Timer, dic *di.Container) bool { configuration := container.ConfigurationFrom(dic.Get) lc := pkgContainer.LoggingClientFrom(dic.Get) - + lc.Infof("start WebBootstrap BootstrapHandler in...") - + //pwd, _ := os.Getwd() LoadWebProxyRoutes(b.router, WebBuildPath, dic) - + if configuration.WebServer.Host == "" || configuration.WebServer.Port == 0 { lc.Errorf("WebServer Host is null OR port is 0") return false @@ -59,33 +58,33 @@ func (b *WebBootstrap) BootstrapHandler(ctx context.Context, wg *sync.WaitGroup, WriteTimeout: timeout, ReadTimeout: timeout, } - + wg.Add(1) go func() { defer wg.Done() - + <-ctx.Done() lc.Info("WebProxy server shutting down") _ = server.Shutdown(context.Background()) lc.Info("WebProxy server shut down") }() - + lc.Info("WebProxy server starting (" + addr + ")") fmt.Println(color.Red(string(color.LogoContent))) - + tip() fmt.Println(color.Green("Server run at:")) fmt.Printf("- Web: http://localhost:%d/ \r\n", configuration.WebServer.Port) fmt.Println(color.Green("Swagger run at:")) fmt.Printf("- Local: http://localhost:%d/api/v1/swagger/index.html \r\n", configuration.Service.Port) fmt.Printf("%s Enter Control + C Shutdown Server \r\n", time.Now().Format("2006-01-02 15:04:05")) - + wg.Add(1) go func() { defer func() { wg.Done() }() - + err := server.ListenAndServe() if err != nil { lc.Errorf("WebProxy server failed: %v", err) @@ -95,7 +94,7 @@ func (b *WebBootstrap) BootstrapHandler(ctx context.Context, wg *sync.WaitGroup, lc.Info("WebProxy server stopped") } }() - + return true } diff --git a/manifest/docker/db-data/core-data/core.db b/manifest/docker/db-data/core-data/core.db index c86589f..dc25e8b 100644 Binary files a/manifest/docker/db-data/core-data/core.db and b/manifest/docker/db-data/core-data/core.db differ