elasticstream/controller/open.go

40 lines
706 B
Go
Raw Normal View History

2024-10-07 15:25:13 +05:30
package controller
import (
2024-10-07 16:26:41 +05:30
"net/http"
"elasticstream/config"
"elasticstream/source"
2024-10-07 15:25:13 +05:30
"elasticstream/source/elastic"
"github.com/gin-gonic/gin"
)
var client *elastic.Client
func Open(c *gin.Context) {
client = elastic.NewClient()
2024-10-07 16:26:41 +05:30
err := client.Configure(c, config.Config{
2024-10-07 15:25:13 +05:30
Host: "http://test.urantiacloud.com:9200",
Indexes: []string{"index-a", "index-b", "index-c"},
BatchSize: 100,
DBPath: "index.db",
})
if err != nil {
c.Status(http.StatusInternalServerError)
return
}
2024-10-07 16:26:41 +05:30
// get position from boltdb
var positions []source.Position
err = client.Open(c, positions)
2024-10-07 15:25:13 +05:30
if err != nil {
c.Status(http.StatusInternalServerError)
return
}
c.Status(http.StatusOK)
}