Merge branch 'x/gorm' into x/sqlx

r/paopao-ce-plus
Michael Li 2 years ago
commit aa266ac2e9
No known key found for this signature in database

@ -4,9 +4,10 @@ TARGET = paopao-ce
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
TARGET := $(TARGET).exe TARGET := $(TARGET).exe
endif endif
TARGET_BIN = $(basename $(TARGET))
ifeq (n$(CGO_ENABLED),n) ifeq (n$(CGO_ENABLED),n)
CGO_ENABLED := 1 CGO_ENABLED := 0
endif endif
RELEASE_ROOT = release RELEASE_ROOT = release
@ -51,22 +52,22 @@ release: linux-amd64 darwin-amd64 darwin-arm64 windows-x64
.PHONY: linux-amd64 .PHONY: linux-amd64
linux-amd64: linux-amd64:
@echo Build paopao-ce [linux-amd64] CGO_ENABLED=$(CGO_ENABLED) @echo Build paopao-ce [linux-amd64] CGO_ENABLED=$(CGO_ENABLED)
@CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 go build -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(RELEASE_LINUX_AMD64)/$(TARGET) @CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 go build -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(RELEASE_LINUX_AMD64)/$(TARGET_BIN)
.PHONY: darwin-amd64 .PHONY: darwin-amd64
darwin-amd64: darwin-amd64:
@echo Build paopao-ce [darwin-amd64] CGO_ENABLED=$(CGO_ENABLED) @echo Build paopao-ce [darwin-amd64] CGO_ENABLED=$(CGO_ENABLED)
@CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=amd64 go build -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(RELEASE_DARWIN_AMD64)/$(TARGET) @CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=amd64 go build -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(RELEASE_DARWIN_AMD64)/$(TARGET_BIN)
.PHONY: darwin-arm64 .PHONY: darwin-arm64
darwin-arm64: darwin-arm64:
@echo Build paopao-ce [darwin-arm64] CGO_ENABLED=$(CGO_ENABLED) @echo Build paopao-ce [darwin-arm64] CGO_ENABLED=$(CGO_ENABLED)
@CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=arm64 go build -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(RELEASE_DARWIN_ARM64)/$(TARGET) @CGO_ENABLED=$(CGO_ENABLED) GOOS=darwin GOARCH=arm64 go build -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(RELEASE_DARWIN_ARM64)/$(TARGET_BIN)
.PHONY: windows-x64 .PHONY: windows-x64
windows-x64: windows-x64:
@echo Build paopao-ce [windows-x64] CGO_ENABLED=$(CGO_ENABLED) @echo Build paopao-ce [windows-x64] CGO_ENABLED=$(CGO_ENABLED)
@CGO_ENABLED=$(CGO_ENABLED) GOOS=windows GOARCH=amd64 go build -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(RELEASE_WINDOWS_AMD64)/$(basename $(TARGET)).exe @CGO_ENABLED=$(CGO_ENABLED) GOOS=windows GOARCH=amd64 go build -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(RELEASE_WINDOWS_AMD64)/$(TARGET_BIN).exe
.PHONY: generate .PHONY: generate
generate: gen-mir gen-grpc gen-yesql generate: gen-mir gen-grpc gen-yesql

@ -6,56 +6,54 @@ package conf
import ( import (
"log" "log"
"sync"
"time" "time"
"github.com/alimy/cfg" "github.com/alimy/cfg"
) )
var ( var (
loggerSetting *LoggerSettingS loggerSetting *loggerConf
loggerFileSetting *LoggerFileSettingS loggerFileSetting *loggerFileConf
loggerZincSetting *LoggerZincSettingS loggerZincSetting *loggerZincConf
loggerMeiliSetting *LoggerMeiliSettingS loggerMeiliSetting *loggerMeiliConf
sentrySetting *SentrySettingS sentrySetting *sentryConf
redisSetting *RedisSettingS redisSetting *redisConf
PyroscopeSetting *PyroscopeSettingS PyroscopeSetting *pyroscopeConf
DatabaseSetting *DatabaseSetingS DatabaseSetting *databaseConf
MysqlSetting *MySQLSettingS MysqlSetting *mysqlConf
PostgresSetting *PostgresSettingS PostgresSetting *postgresConf
Sqlite3Setting *Sqlite3SettingS Sqlite3Setting *sqlite3Conf
WebServerSetting *HttpServerSettingS WebServerSetting *httpServerConf
AdminServerSetting *HttpServerSettingS AdminServerSetting *httpServerConf
SpaceXServerSetting *HttpServerSettingS SpaceXServerSetting *httpServerConf
BotServerSetting *HttpServerSettingS BotServerSetting *httpServerConf
LocalossServerSetting *HttpServerSettingS LocalossServerSetting *httpServerConf
FrontendWebSetting *HttpServerSettingS FrontendWebSetting *httpServerConf
DocsServerSetting *HttpServerSettingS DocsServerSetting *httpServerConf
MobileServerSetting *GRPCServerSettingS MobileServerSetting *grpcServerConf
AppSetting *AppSettingS AppSetting *appConf
CacheIndexSetting *CacheIndexSettingS CacheIndexSetting *cacheIndexConf
SimpleCacheIndexSetting *SimpleCacheIndexSettingS SimpleCacheIndexSetting *simpleCacheIndexConf
BigCacheIndexSetting *BigCacheIndexSettingS BigCacheIndexSetting *bigCacheIndexConf
RedisCacheIndexSetting *RedisCacheIndexSettingS RedisCacheIndexSetting *redisCacheIndexConf
SmsJuheSetting *SmsJuheSettings SmsJuheSetting *smsJuheConf
AlipaySetting *AlipaySettingS AlipaySetting *alipayConf
TweetSearchSetting *TweetSearchS TweetSearchSetting *tweetSearchConf
ZincSetting *ZincSettingS ZincSetting *zincConf
MeiliSetting *MeiliSettingS MeiliSetting *meiliConf
ObjectStorage *ObjectStorageS ObjectStorage *objectStorageS
AliOSSSetting *AliOSSSettingS AliOSSSetting *aliOSSConf
COSSetting *COSSettingS COSSetting *cosConf
HuaweiOBSSetting *HuaweiOBSSettingS HuaweiOBSSetting *huaweiOBSConf
MinIOSetting *MinIOSettingS MinIOSetting *minioConf
S3Setting *S3SettingS S3Setting *s3Conf
LocalOSSSetting *LocalOSSSettingS LocalOSSSetting *localossConf
JWTSetting *JWTSettingS JWTSetting *jwtConf
Mutex *sync.Mutex
) )
func setupSetting(suite []string, noDefault bool) error { func setupSetting(suite []string, noDefault bool) error {
setting, err := NewSetting() setting, err := newSetting()
if err != nil { if err != nil {
return err return err
} }
@ -117,11 +115,10 @@ func setupSetting(suite []string, noDefault bool) error {
RedisCacheIndexSetting.ExpireInSecond *= time.Second RedisCacheIndexSetting.ExpireInSecond *= time.Second
redisSetting.ConnWriteTimeout *= time.Second redisSetting.ConnWriteTimeout *= time.Second
Mutex = &sync.Mutex{}
return nil return nil
} }
func Initialize(suite []string, noDefault bool) { func Initial(suite []string, noDefault bool) {
err := setupSetting(suite, noDefault) err := setupSetting(suite, noDefault)
if err != nil { if err != nil {
log.Fatalf("init.setupSetting err: %v", err) log.Fatalf("init.setupSetting err: %v", err)

@ -1,36 +1,27 @@
// Copyright 2022 ROC. All rights reserved. // Copyright 2023 ROC. All rights reserved.
// Use of this source code is governed by a MIT style // Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package conf package conf
import ( import (
"embed"
"fmt" "fmt"
"strings" "strings"
"time" "time"
"github.com/pyroscope-io/client/pyroscope" "github.com/pyroscope-io/client/pyroscope"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"gorm.io/gorm/logger" "gorm.io/gorm/logger"
) )
//go:embed config.yaml type pyroscopeConf struct {
var files embed.FS
type Setting struct {
vp *viper.Viper
}
type PyroscopeSettingS struct {
AppName string AppName string
Endpoint string Endpoint string
AuthToken string AuthToken string
Logger string Logger string
} }
type SentrySettingS struct { type sentryConf struct {
Dsn string Dsn string
Debug bool Debug bool
AttachStacktrace bool AttachStacktrace bool
@ -39,17 +30,17 @@ type SentrySettingS struct {
AttachGin bool AttachGin bool
} }
type LoggerSettingS struct { type loggerConf struct {
Level string Level string
} }
type LoggerFileSettingS struct { type loggerFileConf struct {
SavePath string SavePath string
FileName string FileName string
FileExt string FileExt string
} }
type LoggerZincSettingS struct { type loggerZincConf struct {
Host string Host string
Index string Index string
User string User string
@ -57,7 +48,7 @@ type LoggerZincSettingS struct {
Secure bool Secure bool
} }
type LoggerMeiliSettingS struct { type loggerMeiliConf struct {
Host string Host string
Index string Index string
ApiKey string ApiKey string
@ -66,7 +57,7 @@ type LoggerMeiliSettingS struct {
MinWorker int MinWorker int
} }
type HttpServerSettingS struct { type httpServerConf struct {
RunMode string RunMode string
HttpIp string HttpIp string
HttpPort string HttpPort string
@ -74,12 +65,12 @@ type HttpServerSettingS struct {
WriteTimeout time.Duration WriteTimeout time.Duration
} }
type GRPCServerSettingS struct { type grpcServerConf struct {
Host string Host string
Port string Port string
} }
type AppSettingS struct { type appConf struct {
RunMode string RunMode string
MaxCommentCount int64 MaxCommentCount int64
AttachmentIncomeRate float64 AttachmentIncomeRate float64
@ -88,30 +79,30 @@ type AppSettingS struct {
MaxPageSize int MaxPageSize int
} }
type CacheIndexSettingS struct { type cacheIndexConf struct {
MaxUpdateQPS int MaxUpdateQPS int
MinWorker int MinWorker int
} }
type SimpleCacheIndexSettingS struct { type simpleCacheIndexConf struct {
MaxIndexSize int MaxIndexSize int
CheckTickDuration time.Duration CheckTickDuration time.Duration
ExpireTickDuration time.Duration ExpireTickDuration time.Duration
} }
type BigCacheIndexSettingS struct { type bigCacheIndexConf struct {
MaxIndexPage int MaxIndexPage int
HardMaxCacheSize int HardMaxCacheSize int
ExpireInSecond time.Duration ExpireInSecond time.Duration
Verbose bool Verbose bool
} }
type RedisCacheIndexSettingS struct { type redisCacheIndexConf struct {
ExpireInSecond time.Duration ExpireInSecond time.Duration
Verbose bool Verbose bool
} }
type AlipaySettingS struct { type alipayConf struct {
AppID string AppID string
PrivateKey string PrivateKey string
RootCertFile string RootCertFile string
@ -120,19 +111,19 @@ type AlipaySettingS struct {
InProduction bool InProduction bool
} }
type SmsJuheSettings struct { type smsJuheConf struct {
Gateway string Gateway string
Key string Key string
TplID string TplID string
TplVal string TplVal string
} }
type TweetSearchS struct { type tweetSearchConf struct {
MaxUpdateQPS int MaxUpdateQPS int
MinWorker int MinWorker int
} }
type ZincSettingS struct { type zincConf struct {
Host string Host string
Index string Index string
User string User string
@ -140,19 +131,19 @@ type ZincSettingS struct {
Secure bool Secure bool
} }
type MeiliSettingS struct { type meiliConf struct {
Host string Host string
Index string Index string
ApiKey string ApiKey string
Secure bool Secure bool
} }
type DatabaseSetingS struct { type databaseConf struct {
TablePrefix string TablePrefix string
LogLevel string LogLevel string
} }
type MySQLSettingS struct { type mysqlConf struct {
UserName string UserName string
Password string Password string
Host string Host string
@ -163,18 +154,18 @@ type MySQLSettingS struct {
MaxOpenConns int MaxOpenConns int
} }
type PostgresSettingS map[string]string type postgresConf map[string]string
type Sqlite3SettingS struct { type sqlite3Conf struct {
Path string Path string
} }
type ObjectStorageS struct { type objectStorageS struct {
RetainInDays int RetainInDays int
TempDir string TempDir string
} }
type MinIOSettingS struct { type minioConf struct {
AccessKey string AccessKey string
SecretKey string SecretKey string
Secure bool Secure bool
@ -183,7 +174,7 @@ type MinIOSettingS struct {
Domain string Domain string
} }
type S3SettingS struct { type s3Conf struct {
AccessKey string AccessKey string
SecretKey string SecretKey string
Secure bool Secure bool
@ -192,7 +183,7 @@ type S3SettingS struct {
Domain string Domain string
} }
type AliOSSSettingS struct { type aliOSSConf struct {
AccessKeyID string AccessKeyID string
AccessKeySecret string AccessKeySecret string
Endpoint string Endpoint string
@ -200,7 +191,7 @@ type AliOSSSettingS struct {
Domain string Domain string
} }
type COSSettingS struct { type cosConf struct {
SecretID string SecretID string
SecretKey string SecretKey string
Region string Region string
@ -208,7 +199,7 @@ type COSSettingS struct {
Domain string Domain string
} }
type HuaweiOBSSettingS struct { type huaweiOBSConf struct {
AccessKey string AccessKey string
SecretKey string SecretKey string
Endpoint string Endpoint string
@ -216,14 +207,14 @@ type HuaweiOBSSettingS struct {
Domain string Domain string
} }
type LocalOSSSettingS struct { type localossConf struct {
SavePath string SavePath string
Secure bool Secure bool
Bucket string Bucket string
Domain string Domain string
} }
type RedisSettingS struct { type redisConf struct {
InitAddress []string InitAddress []string
Username string Username string
Password string Password string
@ -231,79 +222,21 @@ type RedisSettingS struct {
ConnWriteTimeout time.Duration ConnWriteTimeout time.Duration
} }
type JWTSettingS struct { type jwtConf struct {
Secret string Secret string
Issuer string Issuer string
Expire time.Duration Expire time.Duration
} }
func NewSetting() (*Setting, error) { func (s *httpServerConf) GetReadTimeout() time.Duration {
cfgFile, err := files.Open("config.yaml")
if err != nil {
return nil, err
}
defer cfgFile.Close()
vp := viper.New()
vp.SetConfigName("config")
vp.AddConfigPath(".")
vp.AddConfigPath("custom/")
vp.SetConfigType("yaml")
if err = vp.ReadConfig(cfgFile); err != nil {
return nil, err
}
if err = vp.MergeInConfig(); err != nil {
return nil, err
}
return &Setting{vp}, nil
}
func (s *Setting) ReadSection(k string, v any) error {
err := s.vp.UnmarshalKey(k, v)
if err != nil {
return err
}
return nil
}
func (s *Setting) Unmarshal(objects map[string]any) error {
for k, v := range objects {
err := s.vp.UnmarshalKey(k, v)
if err != nil {
return err
}
}
return nil
}
func (s *Setting) featuresInfoFrom(k string) (map[string][]string, map[string]string) {
sub := s.vp.Sub(k)
keys := sub.AllKeys()
suites := make(map[string][]string)
kv := make(map[string]string, len(keys))
for _, key := range sub.AllKeys() {
val := sub.Get(key)
switch v := val.(type) {
case string:
kv[key] = v
case []any:
suites[key] = sub.GetStringSlice(key)
}
}
return suites, kv
}
func (s *HttpServerSettingS) GetReadTimeout() time.Duration {
return s.ReadTimeout * time.Second return s.ReadTimeout * time.Second
} }
func (s *HttpServerSettingS) GetWriteTimeout() time.Duration { func (s *httpServerConf) GetWriteTimeout() time.Duration {
return s.WriteTimeout * time.Second return s.WriteTimeout * time.Second
} }
func (s *MySQLSettingS) Dsn() string { func (s *mysqlConf) Dsn() string {
return fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=%s&parseTime=%t&loc=Local", return fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=%s&parseTime=%t&loc=Local",
s.UserName, s.UserName,
s.Password, s.Password,
@ -314,7 +247,7 @@ func (s *MySQLSettingS) Dsn() string {
) )
} }
func (s PostgresSettingS) Dsn() string { func (s postgresConf) Dsn() string {
var params []string var params []string
for k, v := range s { for k, v := range s {
if len(v) == 0 { if len(v) == 0 {
@ -334,7 +267,7 @@ func (s PostgresSettingS) Dsn() string {
return strings.Join(params, " ") return strings.Join(params, " ")
} }
func (s *Sqlite3SettingS) Dsn(driverName string) string { func (s *sqlite3Conf) Dsn(driverName string) string {
pragmas := "_foreign_keys=1&_journal_mode=WAL&_synchronous=NORMAL&_busy_timeout=8000" pragmas := "_foreign_keys=1&_journal_mode=WAL&_synchronous=NORMAL&_busy_timeout=8000"
if driverName == "sqlite" { if driverName == "sqlite" {
pragmas = "_pragma=foreign_keys(1)&_pragma=journal_mode(WAL)&_pragma=synchronous(NORMAL)&_pragma=busy_timeout(8000)&_pragma=journal_size_limit(100000000)" pragmas = "_pragma=foreign_keys(1)&_pragma=journal_mode(WAL)&_pragma=synchronous(NORMAL)&_pragma=busy_timeout(8000)&_pragma=journal_size_limit(100000000)"
@ -342,7 +275,7 @@ func (s *Sqlite3SettingS) Dsn(driverName string) string {
return fmt.Sprintf("file:%s?%s", s.Path, pragmas) return fmt.Sprintf("file:%s?%s", s.Path, pragmas)
} }
func (s *DatabaseSetingS) logLevel() logger.LogLevel { func (s *databaseConf) logLevel() logger.LogLevel {
switch strings.ToLower(s.LogLevel) { switch strings.ToLower(s.LogLevel) {
case "silent": case "silent":
return logger.Silent return logger.Silent
@ -357,7 +290,7 @@ func (s *DatabaseSetingS) logLevel() logger.LogLevel {
} }
} }
func (s *LoggerSettingS) logLevel() logrus.Level { func (s *loggerConf) logLevel() logrus.Level {
switch strings.ToLower(s.Level) { switch strings.ToLower(s.Level) {
case "panic": case "panic":
return logrus.PanicLevel return logrus.PanicLevel
@ -378,15 +311,15 @@ func (s *LoggerSettingS) logLevel() logrus.Level {
} }
} }
func (s *LoggerZincSettingS) Endpoint() string { func (s *loggerZincConf) Endpoint() string {
return endpoint(s.Host, s.Secure) return endpoint(s.Host, s.Secure)
} }
func (s *LoggerMeiliSettingS) Endpoint() string { func (s *loggerMeiliConf) Endpoint() string {
return endpoint(s.Host, s.Secure) return endpoint(s.Host, s.Secure)
} }
func (s *LoggerMeiliSettingS) minWork() int { func (s *loggerMeiliConf) minWork() int {
if s.MinWorker < 5 { if s.MinWorker < 5 {
return 5 return 5
} else if s.MinWorker > 100 { } else if s.MinWorker > 100 {
@ -395,7 +328,7 @@ func (s *LoggerMeiliSettingS) minWork() int {
return s.MinWorker return s.MinWorker
} }
func (s *LoggerMeiliSettingS) maxLogBuffer() int { func (s *loggerMeiliConf) maxLogBuffer() int {
if s.MaxLogBuffer < 10 { if s.MaxLogBuffer < 10 {
return 10 return 10
} else if s.MaxLogBuffer > 1000 { } else if s.MaxLogBuffer > 1000 {
@ -404,19 +337,19 @@ func (s *LoggerMeiliSettingS) maxLogBuffer() int {
return s.MaxLogBuffer return s.MaxLogBuffer
} }
func (s *ObjectStorageS) TempDirSlash() string { func (s *objectStorageS) TempDirSlash() string {
return strings.Trim(s.TempDir, " /") + "/" return strings.Trim(s.TempDir, " /") + "/"
} }
func (s *ZincSettingS) Endpoint() string { func (s *zincConf) Endpoint() string {
return endpoint(s.Host, s.Secure) return endpoint(s.Host, s.Secure)
} }
func (s *MeiliSettingS) Endpoint() string { func (s *meiliConf) Endpoint() string {
return endpoint(s.Host, s.Secure) return endpoint(s.Host, s.Secure)
} }
func (s *DatabaseSetingS) TableNames() (res TableNameMap) { func (s *databaseConf) TableNames() (res TableNameMap) {
tableNames := []string{ tableNames := []string{
TableAnouncement, TableAnouncement,
TableAnouncementContent, TableAnouncementContent,
@ -445,7 +378,7 @@ func (s *DatabaseSetingS) TableNames() (res TableNameMap) {
return return
} }
func (s *PyroscopeSettingS) GetLogger() (logger pyroscope.Logger) { func (s *pyroscopeConf) GetLogger() (logger pyroscope.Logger) {
switch strings.ToLower(s.Logger) { switch strings.ToLower(s.Logger) {
case "standard": case "standard":
logger = pyroscope.StandardLogger logger = pyroscope.StandardLogger

@ -0,0 +1,70 @@
// Copyright 2022 ROC. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package conf
import (
"bytes"
_ "embed"
"github.com/spf13/viper"
)
//go:embed config.yaml
var fileBytes []byte
type setting struct {
vp *viper.Viper
}
func newSetting() (*setting, error) {
vp := viper.New()
vp.SetConfigName("config")
vp.AddConfigPath(".")
vp.AddConfigPath("custom/")
vp.SetConfigType("yaml")
err := vp.ReadConfig(bytes.NewReader(fileBytes))
if err != nil {
return nil, err
}
if err = vp.MergeInConfig(); err != nil {
return nil, err
}
return &setting{vp}, nil
}
func (s *setting) ReadSection(k string, v any) error {
err := s.vp.UnmarshalKey(k, v)
if err != nil {
return err
}
return nil
}
func (s *setting) Unmarshal(objects map[string]any) error {
for k, v := range objects {
err := s.vp.UnmarshalKey(k, v)
if err != nil {
return err
}
}
return nil
}
func (s *setting) featuresInfoFrom(k string) (map[string][]string, map[string]string) {
sub := s.vp.Sub(k)
keys := sub.AllKeys()
suites := make(map[string][]string)
kv := make(map[string]string, len(keys))
for _, key := range sub.AllKeys() {
val := sub.Get(key)
switch v := val.(type) {
case string:
kv[key] = v
case []any:
suites[key] = sub.GetStringSlice(key)
}
}
return suites, kv
}

@ -57,7 +57,7 @@ func NewZincTweetSearchService(ams core.AuthorizationManageService) (core.TweetS
ams: ams, ams: ams,
}, },
indexName: s.Index, indexName: s.Index,
client: zinc.NewClient(s), client: zinc.NewClient(s.Endpoint(), s.User, s.Password),
publicFilter: fmt.Sprintf("visibility:%d", core.PostVisitPublic), publicFilter: fmt.Sprintf("visibility:%d", core.PostVisitPublic),
privateFilter: fmt.Sprintf("visibility:%d AND user_id:%%d", core.PostVisitPrivate), privateFilter: fmt.Sprintf("visibility:%d AND user_id:%%d", core.PostVisitPrivate),
friendFilter: fmt.Sprintf("visibility:%d", core.PostVisitFriend), friendFilter: fmt.Sprintf("visibility:%d", core.PostVisitFriend),

@ -8,7 +8,7 @@ import (
"github.com/rocboss/paopao-ce/internal/migration" "github.com/rocboss/paopao-ce/internal/migration"
) )
func Initialize() { func Initial() {
// migrate database if needed // migrate database if needed
migration.Run() migration.Run()
} }

@ -47,8 +47,8 @@ func (s *suites) Set(value string) error {
func init() { func init() {
flagParse() flagParse()
conf.Initialize(features, noDefaultFeatures) conf.Initial(features, noDefaultFeatures)
internal.Initialize() internal.Initial()
} }
func deferFn() { func deferFn() {

@ -11,7 +11,6 @@ import (
"github.com/cockroachdb/errors" "github.com/cockroachdb/errors"
"github.com/go-resty/resty/v2" "github.com/go-resty/resty/v2"
"github.com/rocboss/paopao-ce/internal/conf"
"github.com/rocboss/paopao-ce/pkg/json" "github.com/rocboss/paopao-ce/pkg/json"
) )
@ -75,12 +74,12 @@ type HitItem struct {
} }
// NewClient 获取ZincClient新实例 // NewClient 获取ZincClient新实例
func NewClient(conf *conf.ZincSettingS) *ZincClient { func NewClient(host, user, passwd string) *ZincClient {
return &ZincClient{ return &ZincClient{
ZincClientConfig: &ZincClientConfig{ ZincClientConfig: &ZincClientConfig{
ZincHost: conf.Endpoint(), ZincHost: host,
ZincUser: conf.User, ZincUser: user,
ZincPassword: conf.Password, ZincPassword: passwd,
}, },
} }
} }

Loading…
Cancel
Save