update for cluster api

This commit is contained in:
medcl 2021-02-20 12:26:37 +08:00
parent 47da5f73b6
commit 2b330a56a7
6 changed files with 21 additions and 24 deletions

View File

@ -1,14 +1,13 @@
package api package api
import ( import (
"log"
"infini.sh/framework/core/api" "infini.sh/framework/core/api"
"infini.sh/framework/core/task" "infini.sh/framework/core/task"
"infini.sh/framework/core/ui" "infini.sh/framework/core/ui"
"infini.sh/search-center/api/index_management" "infini.sh/search-center/api/index_management"
"infini.sh/search-center/config"
"infini.sh/search-center/api/system" "infini.sh/search-center/api/system"
"infini.sh/search-center/config"
log "github.com/cihub/seelog"
) )
func Init(cfg *config.AppConfig) { func Init(cfg *config.AppConfig) {
@ -40,11 +39,11 @@ func Init(cfg *config.AppConfig) {
ui.HandleUIMethod(api.GET, pathPrefix+"cluster/:cluster/version", handler.GetClusterVersion) ui.HandleUIMethod(api.GET, pathPrefix+"cluster/:cluster/version", handler.GetClusterVersion)
task.RegisterScheduleTask(task.ScheduleTask{ task.RegisterScheduleTask(task.ScheduleTask{
Description: "sync reindex task result to index infinireindex", Description: "sync reindex task result",
Task: func() { Task: func() {
err := index_management.SyncRebuildResult(cfg.Elasticsearch) err := index_management.SyncRebuildResult(cfg.Elasticsearch)
if err != nil { if err != nil {
log.Println(err) log.Error(err)
} }
}, },
}) })

View File

@ -35,7 +35,8 @@ func (h *APIHandler) HandleCreateClusterAction(w http.ResponseWriter, req *http.
conf.Created = time.Now() conf.Created = time.Now()
conf.Updated = conf.Created conf.Updated = conf.Created
conf.ID = id conf.ID = id
ir, err := esClient.Index(orm.GetIndexName(model.ClusterConfig{}), "", id, conf) index:=orm.GetIndexName(model.ClusterConfig{})
ir, err := esClient.Index(index, "", id, conf)
if err != nil { if err != nil {
resBody["error"] = err resBody["error"] = err
h.WriteJSON(w, resBody, http.StatusOK) h.WriteJSON(w, resBody, http.StatusOK)

View File

@ -69,9 +69,9 @@ func main() {
module.Start() module.Start()
}, func() { }, func() {
orm.RegisterSchemaWithIndexName(model.Dict{}, "infini-dict") orm.RegisterSchemaWithIndexName(model.Dict{}, "dict")
orm.RegisterSchemaWithIndexName(model.Reindex{}, "infini-reindex") orm.RegisterSchemaWithIndexName(model.Reindex{}, "reindex")
orm.RegisterSchemaWithIndexName(model.ClusterConfig{}, "infini-cluster") orm.RegisterSchemaWithIndexName(model.ClusterConfig{}, "cluster")
}) })
} }

View File

@ -17,8 +17,6 @@ const (
ReindexStatusFailed ReindexStatus = "FAILED" ReindexStatusFailed ReindexStatus = "FAILED"
) )
//const IndexReindex = ".reindex"
type Reindex struct { type Reindex struct {
ID string `json:"id" elastic_meta:"_id"` ID string `json:"id" elastic_meta:"_id"`
Name string `json:"name" elastic_mapping:"name:{type:text}"` Name string `json:"name" elastic_mapping:"name:{type:text}"`

View File

@ -1,8 +1,7 @@
elasticsearch: elasticsearch:
- name: default - name: default
enabled: true enabled: true
endpoint: https://192.168.3.98:8000 endpoint: https://192.168.3.98:9200
index_prefix:
basic_auth: basic_auth:
username: elastic username: elastic
password: ZBdkVQUUdF1Sir4X4BGB password: ZBdkVQUUdF1Sir4X4BGB
@ -28,7 +27,7 @@ modules:
enabled: true enabled: true
init_template: true init_template: true
template_name: ".infini-search-center" template_name: ".infini-search-center"
index_prefix: ".infini-search-center-" index_prefix: ".infini-search-center_"
search-center: search-center:
ui_path: .public ui_path: .public