feat:完善信息

This commit is contained in:
henry
2021-10-15 17:31:23 +08:00
parent ae9fb8ea0f
commit 282448ab6e
5 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1 @@
package api

View File

@ -9,6 +9,7 @@ import (
"SciencesServer/router"
"SciencesServer/rpc/client"
"SciencesServer/serve/cache"
"SciencesServer/serve/es"
"SciencesServer/serve/logger"
"SciencesServer/serve/orm"
"SciencesServer/serve/web"
@ -56,6 +57,8 @@ func (this *Serve) Run() {
cron.Init()
app.Init()
tools.Init()
// 开启Elasticsearch
es.NewEs()(&es.EsConfig{Address: []string{"http://192.168.0.188:9200"}}).Run()
// 开启web
web.NewWeb()(&web.WebConfig{
Port: config.SettingInfo.Server.Port, ReadTimeout: config.SettingInfo.Server.ReadTimeout,

1
go.mod
View File

@ -9,6 +9,7 @@ require (
github.com/casbin/gorm-adapter/v3 v3.4.2
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/elastic/go-elasticsearch/v7 v7.15.0 // indirect
github.com/gin-gonic/gin v1.7.4
github.com/go-redis/redis v6.15.9+incompatible
github.com/golang/protobuf v1.5.2

2
go.sum
View File

@ -83,6 +83,8 @@ github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzq
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/elastic/go-elasticsearch/v7 v7.15.0 h1:kMLoRAO97gAV97YKgn2z/5ExM8pVJeLoJPR0r33OREs=
github.com/elastic/go-elasticsearch/v7 v7.15.0/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=

32
serve/es/es.go Normal file
View File

@ -0,0 +1,32 @@
package es
import "github.com/elastic/go-elasticsearch/v7"
type Es struct{ *EsConfig }
type EsConfig struct {
Address []string
}
type EsServer func(*EsConfig) *Es
var esClient = new(elasticsearch.Client)
func (this *Es) Run() {
obj := elasticsearch.Config{
Addresses: this.Address,
Username: "",
Password: "",
}
var err error
if esClient, err = elasticsearch.NewClient(obj); err != nil {
panic("Elasticsearch Error " + err.Error())
}
}
func NewEs() EsServer {
return func(config *EsConfig) *Es {
return &Es{config}
}
}