update for cluster api
This commit is contained in:
parent
47da5f73b6
commit
2b330a56a7
|
@ -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)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -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)
|
||||||
|
|
6
main.go
6
main.go
|
@ -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")
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,14 @@ package model
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
type ClusterConfig struct {
|
type ClusterConfig 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}"`
|
||||||
Endpoint string `json:"endpoint" elastic_mapping:"endpoint:{type:text}"`
|
Endpoint string `json:"endpoint" elastic_mapping:"endpoint:{type:text}"`
|
||||||
UserName string `json:"username" elastic_mapping:"username:{type:keyword}"`
|
UserName string `json:"username" elastic_mapping:"username:{type:keyword}"`
|
||||||
Password string `json:"password" elastic_mapping:"password:{type:keyword}" `
|
Password string `json:"password" elastic_mapping:"password:{type:keyword}" `
|
||||||
Order int `json:"order" elastic_mapping:"order:{type:integer}"`
|
Order int `json:"order" elastic_mapping:"order:{type:integer}"`
|
||||||
Description string `json:"description" elastic_mapping:"description:{type:text}"`
|
Description string `json:"description" elastic_mapping:"description:{type:text}"`
|
||||||
Enabled bool `json:"enabled" elastic_mapping:"enabled:{type:boolean}"`
|
Enabled bool `json:"enabled" elastic_mapping:"enabled:{type:boolean}"`
|
||||||
Created time.Time `json:"created" elastic_mapping:"created:{type:date}"`
|
Created time.Time `json:"created" elastic_mapping:"created:{type:date}"`
|
||||||
Updated time.Time `json:"updated" elastic_mapping:"updated:{type:date}"`
|
Updated time.Time `json:"updated" elastic_mapping:"updated:{type:date}"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}"`
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue