Skip to content

Commit

Permalink
feat: add redis driver for mq
Browse files Browse the repository at this point in the history
  • Loading branch information
MuZhou233 committed Mar 2, 2024
1 parent 92b5aef commit 02dc32b
Show file tree
Hide file tree
Showing 43 changed files with 586 additions and 598 deletions.
3 changes: 2 additions & 1 deletion app/sephirah/cmd/sephirah/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func main() {

app, cleanup, err := wireApp(
bc.GetServer(),
bc.GetData(),
bc.GetDatabase(),
bc.GetS3(),
bc.GetPorter(),
bc.GetAuth(),
bc.GetMq(),
Expand Down
3 changes: 2 additions & 1 deletion app/sephirah/cmd/sephirah/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import (
// wireApp init kratos application.
func wireApp(
*conf.SephirahServer,
*conf.SephirahData,
*conf.Database,
*conf.S3,
*conf.Porter,
*conf.Auth,
*conf.MQ,
Expand Down
8 changes: 4 additions & 4 deletions app/sephirah/cmd/sephirah/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions app/sephirah/internal/data/binah.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ type binahRepo struct {
buckets map[bizbinah.Bucket]string
}

func NewBinahRepo(c *conf.SephirahData) (bizbinah.BinahRepo, error) {
if c == nil || c.GetS3() == nil {
func NewBinahRepo(c *conf.S3) (bizbinah.BinahRepo, error) {
if c == nil {
return new(binahRepo), nil
}
minioClient, err := minio.New(c.GetS3().GetEndPoint(), &minio.Options{ //nolint:exhaustruct //TODO
Creds: credentials.NewStaticV4(c.GetS3().GetAccessKey(), c.GetS3().GetSecretKey(), ""),
Secure: c.GetS3().GetUseSsl(),
minioClient, err := minio.New(c.GetEndPoint(), &minio.Options{ //nolint:exhaustruct //TODO
Creds: credentials.NewStaticV4(c.GetAccessKey(), c.GetSecretKey(), ""),
Secure: c.GetUseSsl(),
})
if err != nil {
return nil, err
Expand Down
18 changes: 9 additions & 9 deletions app/sephirah/internal/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ func NewData(db *ent.Client) *Data {
}
}

func NewSQLClient(c *conf.SephirahData, app *libapp.Settings) (*ent.Client, func(), error) {
func NewSQLClient(c *conf.Database, app *libapp.Settings) (*ent.Client, func(), error) {
var driverName, dataSourceName string
if c == nil {
c = new(conf.SephirahData)
c = new(conf.Database)
}
driverName = c.GetDatabase().GetDriver()
driverName = c.GetDriver()
if driverName == "" {
logger.Warnf("database driver is empty, using memory mode.")
driverName = driverMemory
Expand All @@ -68,13 +68,13 @@ func NewSQLClient(c *conf.SephirahData, app *libapp.Settings) (*ent.Client, func
dataSourceName = fmt.Sprintf("file:%s?cache=shared&_fk=1", path.Join(app.DataPath, "librarian.db"))
case driverPostgres:
dataSourceName = fmt.Sprintf("host=%s port=%d user=%s dbname=%s password=%s",
c.GetDatabase().GetHost(),
c.GetDatabase().GetPort(),
c.GetDatabase().GetUser(),
c.GetDatabase().GetDbname(),
c.GetDatabase().GetPassword(),
c.GetHost(),
c.GetPort(),
c.GetUser(),
c.GetDbname(),
c.GetPassword(),
)
if c.GetDatabase().GetNoSsl() {
if c.GetNoSsl() {
dataSourceName += " sslmode=disable"
}
default:
Expand Down
8 changes: 3 additions & 5 deletions app/sephirah/internal/data/internal/ent/account.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions app/sephirah/internal/data/internal/ent/app.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions app/sephirah/internal/data/internal/ent/appbinary.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions app/sephirah/internal/data/internal/ent/appinfo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions app/sephirah/internal/data/internal/ent/appinst.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions app/sephirah/internal/data/internal/ent/feed.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions app/sephirah/internal/data/internal/ent/feedconfig.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions app/sephirah/internal/data/internal/ent/feeditem.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions app/sephirah/internal/data/internal/ent/file.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions app/sephirah/internal/data/internal/ent/image.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions app/sephirah/internal/data/internal/ent/notifyflow.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions app/sephirah/internal/data/internal/ent/notifyflowsource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 02dc32b

Please sign in to comment.