From 02dc32b14e9d6e21fae7f47eda8fbac0274828cc Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Sat, 2 Mar 2024 17:08:48 +0000 Subject: [PATCH] feat: add redis driver for mq --- app/sephirah/cmd/sephirah/main.go | 3 +- app/sephirah/cmd/sephirah/wire.go | 3 +- app/sephirah/cmd/sephirah/wire_gen.go | 8 +- app/sephirah/internal/data/binah.go | 10 +- app/sephirah/internal/data/data.go | 18 +- .../internal/data/internal/ent/account.go | 8 +- .../internal/data/internal/ent/app.go | 16 +- .../internal/data/internal/ent/appbinary.go | 8 +- .../internal/data/internal/ent/appinfo.go | 8 +- .../internal/data/internal/ent/appinst.go | 8 +- .../internal/data/internal/ent/feed.go | 8 +- .../internal/data/internal/ent/feedconfig.go | 16 +- .../internal/data/internal/ent/feeditem.go | 8 +- .../internal/data/internal/ent/file.go | 16 +- .../internal/data/internal/ent/image.go | 16 +- .../internal/data/internal/ent/notifyflow.go | 8 +- .../data/internal/ent/notifyflowsource.go | 16 +- .../data/internal/ent/notifyflowtarget.go | 16 +- .../data/internal/ent/notifytarget.go | 8 +- .../data/internal/ent/runtime/runtime.go | 4 +- .../internal/data/internal/ent/user.go | 8 +- .../internal/data/internal/ent/userdevice.go | 16 +- .../internal/data/internal/ent/usersession.go | 8 +- .../internal/model/converter/biz_to_pb.go | 1 + app/sephirah/pkg/service/wire.go | 3 +- app/sephirah/pkg/service/wire_gen.go | 6 +- cmd/librarian/main.go | 3 +- cmd/librarian/wire.go | 3 +- cmd/librarian/wire_gen.go | 6 +- configs/example-for-single-node.yaml | 40 +-- configs/example-for-testing.yaml | 7 +- go.mod | 4 + go.sum | 9 +- internal/conf/base.pb.go | 253 +++++++++---- internal/conf/base.proto | 12 +- internal/conf/librarian.pb.go | 158 +++++---- internal/conf/librarian.proto | 15 +- internal/conf/sephirah.pb.go | 333 +++++------------- internal/conf/sephirah.proto | 26 +- internal/lib/libcache/cache.go | 9 +- internal/lib/libmq/mq.go | 16 +- internal/lib/libmq/mq_redis.go | 36 ++ tests/docker-compose.yaml | 6 + 43 files changed, 586 insertions(+), 598 deletions(-) create mode 100644 internal/lib/libmq/mq_redis.go diff --git a/app/sephirah/cmd/sephirah/main.go b/app/sephirah/cmd/sephirah/main.go index 2d20e10d..323a8c64 100644 --- a/app/sephirah/cmd/sephirah/main.go +++ b/app/sephirah/cmd/sephirah/main.go @@ -58,7 +58,8 @@ func main() { app, cleanup, err := wireApp( bc.GetServer(), - bc.GetData(), + bc.GetDatabase(), + bc.GetS3(), bc.GetPorter(), bc.GetAuth(), bc.GetMq(), diff --git a/app/sephirah/cmd/sephirah/wire.go b/app/sephirah/cmd/sephirah/wire.go index e0418b2e..9ab28d41 100644 --- a/app/sephirah/cmd/sephirah/wire.go +++ b/app/sephirah/cmd/sephirah/wire.go @@ -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, diff --git a/app/sephirah/cmd/sephirah/wire_gen.go b/app/sephirah/cmd/sephirah/wire_gen.go index ad886d53..1bf44a8a 100644 --- a/app/sephirah/cmd/sephirah/wire_gen.go +++ b/app/sephirah/cmd/sephirah/wire_gen.go @@ -32,16 +32,16 @@ import ( // Injectors from wire.go: // wireApp init kratos application. -func wireApp(sephirahServer *conf.SephirahServer, sephirahData *conf.SephirahData, porter *conf.Porter, auth *conf.Auth, mq *conf.MQ, cache *conf.Cache, consul *conf.Consul, settings *libapp.Settings) (*kratos.App, func(), error) { +func wireApp(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *conf.S3, porter *conf.Porter, auth *conf.Auth, mq *conf.MQ, cache *conf.Cache, consul *conf.Consul, settings *libapp.Settings) (*kratos.App, func(), error) { libauthAuth, err := libauth.NewAuth(auth) if err != nil { return nil, nil, err } - libmqMQ, cleanup, err := libmq.NewMQ(mq, settings) + libmqMQ, cleanup, err := libmq.NewMQ(mq, database, cache, settings) if err != nil { return nil, nil, err } - entClient, cleanup2, err := data.NewSQLClient(sephirahData, settings) + entClient, cleanup2, err := data.NewSQLClient(database, settings) if err != nil { cleanup() return nil, nil, err @@ -119,7 +119,7 @@ func wireApp(sephirahServer *conf.SephirahServer, sephirahData *conf.SephirahDat return nil, nil, err } gebura := bizgebura.NewGebura(geburaRepo, libauthAuth, searcher, topic, libmqTopic, libcacheMap) - binahRepo, err := data.NewBinahRepo(sephirahData) + binahRepo, err := data.NewBinahRepo(s3) if err != nil { cleanup2() cleanup() diff --git a/app/sephirah/internal/data/binah.go b/app/sephirah/internal/data/binah.go index 7ea8f38c..71f3203f 100644 --- a/app/sephirah/internal/data/binah.go +++ b/app/sephirah/internal/data/binah.go @@ -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 diff --git a/app/sephirah/internal/data/data.go b/app/sephirah/internal/data/data.go index dd80bfba..718d2c39 100644 --- a/app/sephirah/internal/data/data.go +++ b/app/sephirah/internal/data/data.go @@ -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 @@ -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: diff --git a/app/sephirah/internal/data/internal/ent/account.go b/app/sephirah/internal/data/internal/ent/account.go index 353930bd..2838f145 100644 --- a/app/sephirah/internal/data/internal/ent/account.go +++ b/app/sephirah/internal/data/internal/ent/account.go @@ -63,12 +63,10 @@ func (e AccountEdges) PurchasedAppOrErr() ([]*AppInfo, error) { // BindUserOrErr returns the BindUser value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e AccountEdges) BindUserOrErr() (*User, error) { - if e.loadedTypes[1] { - if e.BindUser == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.BindUser != nil { return e.BindUser, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "bind_user"} } diff --git a/app/sephirah/internal/data/internal/ent/app.go b/app/sephirah/internal/data/internal/ent/app.go index e00e19d9..9c68adfe 100644 --- a/app/sephirah/internal/data/internal/ent/app.go +++ b/app/sephirah/internal/data/internal/ent/app.go @@ -52,12 +52,10 @@ type AppEdges struct { // OwnerOrErr returns the Owner value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e AppEdges) OwnerOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.Owner == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.Owner != nil { return e.Owner, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "owner"} } @@ -65,12 +63,10 @@ func (e AppEdges) OwnerOrErr() (*User, error) { // AppInfoOrErr returns the AppInfo value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e AppEdges) AppInfoOrErr() (*AppInfo, error) { - if e.loadedTypes[1] { - if e.AppInfo == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: appinfo.Label} - } + if e.AppInfo != nil { return e.AppInfo, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: appinfo.Label} } return nil, &NotLoadedError{edge: "app_info"} } diff --git a/app/sephirah/internal/data/internal/ent/appbinary.go b/app/sephirah/internal/data/internal/ent/appbinary.go index 294bde54..efe7e4c8 100644 --- a/app/sephirah/internal/data/internal/ent/appbinary.go +++ b/app/sephirah/internal/data/internal/ent/appbinary.go @@ -50,12 +50,10 @@ type AppBinaryEdges struct { // AppInfoOrErr returns the AppInfo value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e AppBinaryEdges) AppInfoOrErr() (*AppInfo, error) { - if e.loadedTypes[0] { - if e.AppInfo == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: appinfo.Label} - } + if e.AppInfo != nil { return e.AppInfo, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: appinfo.Label} } return nil, &NotLoadedError{edge: "app_info"} } diff --git a/app/sephirah/internal/data/internal/ent/appinfo.go b/app/sephirah/internal/data/internal/ent/appinfo.go index f2b62c4b..2755c660 100644 --- a/app/sephirah/internal/data/internal/ent/appinfo.go +++ b/app/sephirah/internal/data/internal/ent/appinfo.go @@ -117,12 +117,10 @@ func (e AppInfoEdges) AppBinaryOrErr() ([]*AppBinary, error) { // BindInternalOrErr returns the BindInternal value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e AppInfoEdges) BindInternalOrErr() (*AppInfo, error) { - if e.loadedTypes[4] { - if e.BindInternal == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: appinfo.Label} - } + if e.BindInternal != nil { return e.BindInternal, nil + } else if e.loadedTypes[4] { + return nil, &NotFoundError{label: appinfo.Label} } return nil, &NotLoadedError{edge: "bind_internal"} } diff --git a/app/sephirah/internal/data/internal/ent/appinst.go b/app/sephirah/internal/data/internal/ent/appinst.go index 300dd6dd..05eacb9a 100644 --- a/app/sephirah/internal/data/internal/ent/appinst.go +++ b/app/sephirah/internal/data/internal/ent/appinst.go @@ -46,12 +46,10 @@ type AppInstEdges struct { // OwnerOrErr returns the Owner value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e AppInstEdges) OwnerOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.Owner == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.Owner != nil { return e.Owner, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "owner"} } diff --git a/app/sephirah/internal/data/internal/ent/feed.go b/app/sephirah/internal/data/internal/ent/feed.go index bbe8ad29..33a3b42d 100644 --- a/app/sephirah/internal/data/internal/ent/feed.go +++ b/app/sephirah/internal/data/internal/ent/feed.go @@ -67,12 +67,10 @@ func (e FeedEdges) ItemOrErr() ([]*FeedItem, error) { // ConfigOrErr returns the Config value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e FeedEdges) ConfigOrErr() (*FeedConfig, error) { - if e.loadedTypes[1] { - if e.Config == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: feedconfig.Label} - } + if e.Config != nil { return e.Config, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: feedconfig.Label} } return nil, &NotLoadedError{edge: "config"} } diff --git a/app/sephirah/internal/data/internal/ent/feedconfig.go b/app/sephirah/internal/data/internal/ent/feedconfig.go index 8107ab77..f2c21001 100644 --- a/app/sephirah/internal/data/internal/ent/feedconfig.go +++ b/app/sephirah/internal/data/internal/ent/feedconfig.go @@ -70,12 +70,10 @@ type FeedConfigEdges struct { // OwnerOrErr returns the Owner value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e FeedConfigEdges) OwnerOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.Owner == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.Owner != nil { return e.Owner, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "owner"} } @@ -83,12 +81,10 @@ func (e FeedConfigEdges) OwnerOrErr() (*User, error) { // FeedOrErr returns the Feed value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e FeedConfigEdges) FeedOrErr() (*Feed, error) { - if e.loadedTypes[1] { - if e.Feed == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: feed.Label} - } + if e.Feed != nil { return e.Feed, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: feed.Label} } return nil, &NotLoadedError{edge: "feed"} } diff --git a/app/sephirah/internal/data/internal/ent/feeditem.go b/app/sephirah/internal/data/internal/ent/feeditem.go index c0f16676..6eb32433 100644 --- a/app/sephirah/internal/data/internal/ent/feeditem.go +++ b/app/sephirah/internal/data/internal/ent/feeditem.go @@ -77,12 +77,10 @@ type FeedItemEdges struct { // FeedOrErr returns the Feed value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e FeedItemEdges) FeedOrErr() (*Feed, error) { - if e.loadedTypes[0] { - if e.Feed == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: feed.Label} - } + if e.Feed != nil { return e.Feed, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: feed.Label} } return nil, &NotLoadedError{edge: "feed"} } diff --git a/app/sephirah/internal/data/internal/ent/file.go b/app/sephirah/internal/data/internal/ent/file.go index e15fd5b6..3c5da477 100644 --- a/app/sephirah/internal/data/internal/ent/file.go +++ b/app/sephirah/internal/data/internal/ent/file.go @@ -53,12 +53,10 @@ type FileEdges struct { // OwnerOrErr returns the Owner value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e FileEdges) OwnerOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.Owner == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.Owner != nil { return e.Owner, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "owner"} } @@ -66,12 +64,10 @@ func (e FileEdges) OwnerOrErr() (*User, error) { // ImageOrErr returns the Image value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e FileEdges) ImageOrErr() (*Image, error) { - if e.loadedTypes[1] { - if e.Image == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: image.Label} - } + if e.Image != nil { return e.Image, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: image.Label} } return nil, &NotLoadedError{edge: "image"} } diff --git a/app/sephirah/internal/data/internal/ent/image.go b/app/sephirah/internal/data/internal/ent/image.go index 12514d47..88e6b886 100644 --- a/app/sephirah/internal/data/internal/ent/image.go +++ b/app/sephirah/internal/data/internal/ent/image.go @@ -52,12 +52,10 @@ type ImageEdges struct { // OwnerOrErr returns the Owner value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e ImageEdges) OwnerOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.Owner == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.Owner != nil { return e.Owner, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "owner"} } @@ -65,12 +63,10 @@ func (e ImageEdges) OwnerOrErr() (*User, error) { // FileOrErr returns the File value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e ImageEdges) FileOrErr() (*File, error) { - if e.loadedTypes[1] { - if e.File == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: file.Label} - } + if e.File != nil { return e.File, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: file.Label} } return nil, &NotLoadedError{edge: "file"} } diff --git a/app/sephirah/internal/data/internal/ent/notifyflow.go b/app/sephirah/internal/data/internal/ent/notifyflow.go index 471c74de..dd2ff4d2 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflow.go +++ b/app/sephirah/internal/data/internal/ent/notifyflow.go @@ -56,12 +56,10 @@ type NotifyFlowEdges struct { // OwnerOrErr returns the Owner value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e NotifyFlowEdges) OwnerOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.Owner == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.Owner != nil { return e.Owner, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "owner"} } diff --git a/app/sephirah/internal/data/internal/ent/notifyflowsource.go b/app/sephirah/internal/data/internal/ent/notifyflowsource.go index f4ea234b..0da0276e 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowsource.go +++ b/app/sephirah/internal/data/internal/ent/notifyflowsource.go @@ -53,12 +53,10 @@ type NotifyFlowSourceEdges struct { // NotifyFlowOrErr returns the NotifyFlow value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e NotifyFlowSourceEdges) NotifyFlowOrErr() (*NotifyFlow, error) { - if e.loadedTypes[0] { - if e.NotifyFlow == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: notifyflow.Label} - } + if e.NotifyFlow != nil { return e.NotifyFlow, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: notifyflow.Label} } return nil, &NotLoadedError{edge: "notify_flow"} } @@ -66,12 +64,10 @@ func (e NotifyFlowSourceEdges) NotifyFlowOrErr() (*NotifyFlow, error) { // NotifySourceOrErr returns the NotifySource value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e NotifyFlowSourceEdges) NotifySourceOrErr() (*FeedConfig, error) { - if e.loadedTypes[1] { - if e.NotifySource == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: feedconfig.Label} - } + if e.NotifySource != nil { return e.NotifySource, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: feedconfig.Label} } return nil, &NotLoadedError{edge: "notify_source"} } diff --git a/app/sephirah/internal/data/internal/ent/notifyflowtarget.go b/app/sephirah/internal/data/internal/ent/notifyflowtarget.go index b9b731a0..9a8ae676 100644 --- a/app/sephirah/internal/data/internal/ent/notifyflowtarget.go +++ b/app/sephirah/internal/data/internal/ent/notifyflowtarget.go @@ -55,12 +55,10 @@ type NotifyFlowTargetEdges struct { // NotifyFlowOrErr returns the NotifyFlow value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e NotifyFlowTargetEdges) NotifyFlowOrErr() (*NotifyFlow, error) { - if e.loadedTypes[0] { - if e.NotifyFlow == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: notifyflow.Label} - } + if e.NotifyFlow != nil { return e.NotifyFlow, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: notifyflow.Label} } return nil, &NotLoadedError{edge: "notify_flow"} } @@ -68,12 +66,10 @@ func (e NotifyFlowTargetEdges) NotifyFlowOrErr() (*NotifyFlow, error) { // NotifyTargetOrErr returns the NotifyTarget value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e NotifyFlowTargetEdges) NotifyTargetOrErr() (*NotifyTarget, error) { - if e.loadedTypes[1] { - if e.NotifyTarget == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: notifytarget.Label} - } + if e.NotifyTarget != nil { return e.NotifyTarget, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: notifytarget.Label} } return nil, &NotLoadedError{edge: "notify_target"} } diff --git a/app/sephirah/internal/data/internal/ent/notifytarget.go b/app/sephirah/internal/data/internal/ent/notifytarget.go index 28ab16c5..fd57b2d2 100644 --- a/app/sephirah/internal/data/internal/ent/notifytarget.go +++ b/app/sephirah/internal/data/internal/ent/notifytarget.go @@ -56,12 +56,10 @@ type NotifyTargetEdges struct { // OwnerOrErr returns the Owner value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e NotifyTargetEdges) OwnerOrErr() (*User, error) { - if e.loadedTypes[0] { - if e.Owner == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.Owner != nil { return e.Owner, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "owner"} } diff --git a/app/sephirah/internal/data/internal/ent/runtime/runtime.go b/app/sephirah/internal/data/internal/ent/runtime/runtime.go index 0404e6f6..04d43602 100644 --- a/app/sephirah/internal/data/internal/ent/runtime/runtime.go +++ b/app/sephirah/internal/data/internal/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/runtime.go const ( - Version = "v0.12.5" // Version of ent codegen. - Sum = "h1:KREM5E4CSoej4zeGa88Ou/gfturAnpUv0mzAjch1sj4=" // Sum of ent codegen. + Version = "v0.13.1" // Version of ent codegen. + Sum = "h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE=" // Sum of ent codegen. ) diff --git a/app/sephirah/internal/data/internal/ent/user.go b/app/sephirah/internal/data/internal/ent/user.go index 602a8504..5c23c304 100644 --- a/app/sephirah/internal/data/internal/ent/user.go +++ b/app/sephirah/internal/data/internal/ent/user.go @@ -163,12 +163,10 @@ func (e UserEdges) DeviceInfoOrErr() ([]*DeviceInfo, error) { // CreatorOrErr returns the Creator value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e UserEdges) CreatorOrErr() (*User, error) { - if e.loadedTypes[10] { - if e.Creator == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.Creator != nil { return e.Creator, nil + } else if e.loadedTypes[10] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "creator"} } diff --git a/app/sephirah/internal/data/internal/ent/userdevice.go b/app/sephirah/internal/data/internal/ent/userdevice.go index ae11b39a..29a6fd41 100644 --- a/app/sephirah/internal/data/internal/ent/userdevice.go +++ b/app/sephirah/internal/data/internal/ent/userdevice.go @@ -48,12 +48,10 @@ type UserDeviceEdges struct { // DeviceInfoOrErr returns the DeviceInfo value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e UserDeviceEdges) DeviceInfoOrErr() (*DeviceInfo, error) { - if e.loadedTypes[0] { - if e.DeviceInfo == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: deviceinfo.Label} - } + if e.DeviceInfo != nil { return e.DeviceInfo, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: deviceinfo.Label} } return nil, &NotLoadedError{edge: "device_info"} } @@ -61,12 +59,10 @@ func (e UserDeviceEdges) DeviceInfoOrErr() (*DeviceInfo, error) { // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e UserDeviceEdges) UserOrErr() (*User, error) { - if e.loadedTypes[1] { - if e.User == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: user.Label} - } + if e.User != nil { return e.User, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: user.Label} } return nil, &NotLoadedError{edge: "user"} } diff --git a/app/sephirah/internal/data/internal/ent/usersession.go b/app/sephirah/internal/data/internal/ent/usersession.go index 70c22e68..201aa3d5 100644 --- a/app/sephirah/internal/data/internal/ent/usersession.go +++ b/app/sephirah/internal/data/internal/ent/usersession.go @@ -48,12 +48,10 @@ type UserSessionEdges struct { // DeviceInfoOrErr returns the DeviceInfo value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e UserSessionEdges) DeviceInfoOrErr() (*DeviceInfo, error) { - if e.loadedTypes[0] { - if e.DeviceInfo == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: deviceinfo.Label} - } + if e.DeviceInfo != nil { return e.DeviceInfo, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: deviceinfo.Label} } return nil, &NotLoadedError{edge: "device_info"} } diff --git a/app/sephirah/internal/model/converter/biz_to_pb.go b/app/sephirah/internal/model/converter/biz_to_pb.go index 4f9fe9b1..b2eca9a6 100644 --- a/app/sephirah/internal/model/converter/biz_to_pb.go +++ b/app/sephirah/internal/model/converter/biz_to_pb.go @@ -77,6 +77,7 @@ type toPBConverter interface { //nolint:unused // used by generator ToPBApp(*modelgebura.App) *pb.App ToPBAppList([]*modelgebura.App) []*pb.App // goverter:matchIgnoreCase + // goverter:ignore Id // goverter:ignore TokenServerUrl // goverter:ignore Chunks ToPBAppBinary(*modelgebura.AppBinary) *pb.AppBinary diff --git a/app/sephirah/pkg/service/wire.go b/app/sephirah/pkg/service/wire.go index 84e76b3f..fe802d98 100644 --- a/app/sephirah/pkg/service/wire.go +++ b/app/sephirah/pkg/service/wire.go @@ -27,7 +27,8 @@ import ( func NewSephirahService( *conf.SephirahServer, - *conf.SephirahData, + *conf.Database, + *conf.S3, *conf.Porter, *conf.Consul, *libauth.Auth, diff --git a/app/sephirah/pkg/service/wire_gen.go b/app/sephirah/pkg/service/wire_gen.go index d6e77b3e..17362948 100644 --- a/app/sephirah/pkg/service/wire_gen.go +++ b/app/sephirah/pkg/service/wire_gen.go @@ -32,8 +32,8 @@ import ( // Injectors from wire.go: -func NewSephirahService(sephirahServer *conf.SephirahServer, sephirahData *conf.SephirahData, porter *conf.Porter, consul *conf.Consul, auth *libauth.Auth, mq *libmq.MQ, cron *libcron.Cron, store libcache.Store, settings *libapp.Settings, librarianSearcherServiceClient v1.LibrarianSearcherServiceClient, librarianMinerServiceClient v1_2.LibrarianMinerServiceClient) (v1_3.LibrarianSephirahServiceServer, func(), error) { - entClient, cleanup, err := data.NewSQLClient(sephirahData, settings) +func NewSephirahService(sephirahServer *conf.SephirahServer, database *conf.Database, s3 *conf.S3, porter *conf.Porter, consul *conf.Consul, auth *libauth.Auth, mq *libmq.MQ, cron *libcron.Cron, store libcache.Store, settings *libapp.Settings, librarianSearcherServiceClient v1.LibrarianSearcherServiceClient, librarianMinerServiceClient v1_2.LibrarianMinerServiceClient) (v1_3.LibrarianSephirahServiceServer, func(), error) { + entClient, cleanup, err := data.NewSQLClient(database, settings) if err != nil { return nil, nil, err } @@ -86,7 +86,7 @@ func NewSephirahService(sephirahServer *conf.SephirahServer, sephirahData *conf. return nil, nil, err } gebura := bizgebura.NewGebura(geburaRepo, auth, searcher, topic, libmqTopic, libcacheMap) - binahRepo, err := data.NewBinahRepo(sephirahData) + binahRepo, err := data.NewBinahRepo(s3) if err != nil { cleanup() return nil, nil, err diff --git a/cmd/librarian/main.go b/cmd/librarian/main.go index 03261557..27887321 100644 --- a/cmd/librarian/main.go +++ b/cmd/librarian/main.go @@ -84,7 +84,8 @@ func main() { app, cleanup, err := wireApp( bc.GetEnableServiceDiscovery(), bc.GetServer(), - bc.GetData(), + bc.GetDatabase(), + bc.GetS3(), bc.GetPorter(), bc.GetMapper().GetData(), bc.GetSearcher().GetData(), diff --git a/cmd/librarian/wire.go b/cmd/librarian/wire.go index 93829d80..c73eb0fd 100644 --- a/cmd/librarian/wire.go +++ b/cmd/librarian/wire.go @@ -25,7 +25,8 @@ import ( func wireApp( *conf.Librarian_EnableServiceDiscovery, *conf.SephirahServer, - *conf.SephirahData, + *conf.Database, + *conf.S3, *conf.Porter, *conf.Mapper_Data, *conf.Searcher_Data, diff --git a/cmd/librarian/wire_gen.go b/cmd/librarian/wire_gen.go index d8ddfa08..8e4bd905 100644 --- a/cmd/librarian/wire_gen.go +++ b/cmd/librarian/wire_gen.go @@ -24,12 +24,12 @@ import ( // Injectors from wire.go: // wireApp init kratos application. -func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDiscovery, sephirahServer *conf.SephirahServer, sephirahData *conf.SephirahData, porter *conf.Porter, mapper_Data *conf.Mapper_Data, searcher_Data *conf.Searcher_Data, miner_Data *conf.Miner_Data, auth *conf.Auth, mq *conf.MQ, cache *conf.Cache, consul *conf.Consul, settings *libapp.Settings) (*kratos.App, func(), error) { +func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDiscovery, sephirahServer *conf.SephirahServer, database *conf.Database, s3 *conf.S3, porter *conf.Porter, mapper_Data *conf.Mapper_Data, searcher_Data *conf.Searcher_Data, miner_Data *conf.Miner_Data, auth *conf.Auth, mq *conf.MQ, cache *conf.Cache, consul *conf.Consul, settings *libapp.Settings) (*kratos.App, func(), error) { libauthAuth, err := libauth.NewAuth(auth) if err != nil { return nil, nil, err } - libmqMQ, cleanup, err := libmq.NewMQ(mq, settings) + libmqMQ, cleanup, err := libmq.NewMQ(mq, database, cache, settings) if err != nil { return nil, nil, err } @@ -69,7 +69,7 @@ func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDisco cleanup() return nil, nil, err } - librarianSephirahServiceServer, cleanup4, err := service3.NewSephirahService(sephirahServer, sephirahData, porter, consul, libauthAuth, libmqMQ, cron, store, settings, librarianSearcherServiceClient, librarianMinerServiceClient) + librarianSephirahServiceServer, cleanup4, err := service3.NewSephirahService(sephirahServer, database, s3, porter, consul, libauthAuth, libmqMQ, cron, store, settings, librarianSearcherServiceClient, librarianMinerServiceClient) if err != nil { cleanup3() cleanup2() diff --git a/configs/example-for-single-node.yaml b/configs/example-for-single-node.yaml index 343d6fbc..42ea01c4 100644 --- a/configs/example-for-single-node.yaml +++ b/configs/example-for-single-node.yaml @@ -5,36 +5,28 @@ server: grpc_web: addr: 0.0.0.0:10001 timeout: 1s -data: - database: - driver: postgres - host: localhost - port: 5432 - dbname: librarian - user: librarian - password: librarian - no_ssl: true - s3: - end_point: 127.0.0.1:9000 - access_key: librarian - secret_key: librarian - use_ssl: false +database: + driver: postgres + host: localhost + port: 5432 + dbname: librarian + user: librarian + password: librarian + no_ssl: true +s3: + end_point: 127.0.0.1:9000 + access_key: librarian + secret_key: librarian + use_ssl: false auth: password_salt: test jwt_issuer: test jwt_secret: test mq: - driver: sql - database: - driver: postgres - host: localhost - port: 5432 - dbname: librarian - user: librarian - password: librarian - no_ssl: true + driver: redis cache: - driver: memory + driver: redis + addr: localhost:6379 searcher: data: meilisearch: diff --git a/configs/example-for-testing.yaml b/configs/example-for-testing.yaml index 8c1934ce..939c51f7 100644 --- a/configs/example-for-testing.yaml +++ b/configs/example-for-testing.yaml @@ -5,10 +5,9 @@ server: grpc_web: addr: 0.0.0.0:10001 timeout: 60s -data: - database: - driver: memory - s3: +database: + driver: memory +s3: auth: password_salt: test jwt_issuer: test diff --git a/go.mod b/go.mod index cf42398e..57b14b0c 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/BurntSushi/toml v1.3.2 github.com/PuerkitoBio/goquery v1.9.0 github.com/ThreeDotsLabs/watermill v1.3.5 + github.com/ThreeDotsLabs/watermill-redisstream v1.2.2 github.com/ThreeDotsLabs/watermill-sql/v2 v2.0.0 github.com/blevesearch/bleve/v2 v2.3.10 github.com/bufbuild/protovalidate-go v0.6.0 @@ -50,6 +51,7 @@ require ( require ( ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20240221180331-f05a6f4403ce.1 // indirect + github.com/Rican7/retry v0.3.1 // indirect github.com/RoaringBitmap/roaring v1.2.3 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/andybalholm/brotli v1.0.5 // indirect @@ -158,6 +160,7 @@ require ( github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.40.0 // indirect github.com/vesoft-inc/nebula-go/v2 v2.6.0 // indirect + github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/yusufpapurcu/wmi v1.2.3 // indirect github.com/zclconf/go-cty v1.12.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect @@ -172,6 +175,7 @@ require ( golang.org/x/term v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.18.0 // indirect + google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect diff --git a/go.sum b/go.sum index e3325ad8..ebb24bc6 100644 --- a/go.sum +++ b/go.sum @@ -59,12 +59,16 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/goquery v1.9.0 h1:zgjKkdpRY9T97Q5DCtcXwfqkcylSFIVCocZmn2huTp8= github.com/PuerkitoBio/goquery v1.9.0/go.mod h1:cW1n6TmIMDoORQU5IU/P1T3tGFunOeXEpGP2WHRwkbY= +github.com/Rican7/retry v0.3.1 h1:scY4IbO8swckzoA/11HgBwaZRJEyY9vaNJshcdhp1Mc= +github.com/Rican7/retry v0.3.1/go.mod h1:CxSDrhAyXmTMeEuRAnArMu1FHu48vtfjLREWqVl7Vw0= github.com/RoaringBitmap/roaring v1.2.3 h1:yqreLINqIrX22ErkKI0vY47/ivtJr6n+kMhVOVmhWBY= github.com/RoaringBitmap/roaring v1.2.3/go.mod h1:plvDsJQpxOC5bw8LRteu/MLWHsHez/3y6cubLI4/1yE= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/ThreeDotsLabs/watermill v1.3.5 h1:50JEPEhMGZQMh08ct0tfO1PsgMOAOhV3zxK2WofkbXg= github.com/ThreeDotsLabs/watermill v1.3.5/go.mod h1:O/u/Ptyrk5MPTxSeWM5vzTtZcZfxXfO9PK9eXTYiFZY= +github.com/ThreeDotsLabs/watermill-redisstream v1.2.2 h1:/fFHagJiObMBbYIDrygRoAq+RxqLPcQZdGi6b0ViG08= +github.com/ThreeDotsLabs/watermill-redisstream v1.2.2/go.mod h1:ZRe0VpA0Ho/4MESUrXdqJMaWtiWhi4emxIYpqsxi98Y= github.com/ThreeDotsLabs/watermill-sql/v2 v2.0.0 h1:wswlLYY0Jc0tloj3lty4Y+VTEA8AM1vYfrIDwWtqyJk= github.com/ThreeDotsLabs/watermill-sql/v2 v2.0.0/go.mod h1:83l/4sKaLHwoHJlrAsDLaXcHN+QOHHntAAyabNmiuO4= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= @@ -945,8 +949,6 @@ github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+F github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tuihub/protos v0.4.2 h1:MkwhkXrPWR+YTRU9Vn34RGC4LTtOSRN5oB3FgEDpEMA= -github.com/tuihub/protos v0.4.2/go.mod h1:FvaMeevw4RUzHy5kNgbCHWk3fH25ApXEaNmPvDhXozc= github.com/tuihub/protos v0.4.4 h1:C+iZHYVjyXVZvqVF9DqUNudsheLAEyhHRdA5gt43hJw= github.com/tuihub/protos v0.4.4/go.mod h1:FvaMeevw4RUzHy5kNgbCHWk3fH25ApXEaNmPvDhXozc= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= @@ -969,6 +971,8 @@ github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7Fw github.com/vesoft-inc/nebula-go/v2 v2.0.0-ga/go.mod h1:qvrlydV8O1Jbff7b7cXSLOvZNs9BcE8pFZa/1nvB3fo= github.com/vesoft-inc/nebula-go/v2 v2.6.0 h1:yS5JH8eNjXtHSZXDRcNihdYaW9FyjOsrpG5iIMkIFBs= github.com/vesoft-inc/nebula-go/v2 v2.6.0/go.mod h1:fehDUs97/mpmxXi9WezhznX0Dg7hmQRUoOWgDZv9zG0= +github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= +github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= @@ -1296,6 +1300,7 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= diff --git a/internal/conf/base.pb.go b/internal/conf/base.pb.go index 98a7c339..82b115ef 100644 --- a/internal/conf/base.pb.go +++ b/internal/conf/base.pb.go @@ -179,19 +179,89 @@ func (x *Database) GetNoSsl() bool { return false } +type S3 struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + EndPoint string `protobuf:"bytes,1,opt,name=end_point,json=endPoint,proto3" json:"end_point,omitempty"` + AccessKey string `protobuf:"bytes,2,opt,name=access_key,json=accessKey,proto3" json:"access_key,omitempty"` + SecretKey string `protobuf:"bytes,3,opt,name=secret_key,json=secretKey,proto3" json:"secret_key,omitempty"` + UseSsl bool `protobuf:"varint,4,opt,name=use_ssl,json=useSsl,proto3" json:"use_ssl,omitempty"` +} + +func (x *S3) Reset() { + *x = S3{} + if protoimpl.UnsafeEnabled { + mi := &file_conf_base_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *S3) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*S3) ProtoMessage() {} + +func (x *S3) ProtoReflect() protoreflect.Message { + mi := &file_conf_base_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use S3.ProtoReflect.Descriptor instead. +func (*S3) Descriptor() ([]byte, []int) { + return file_conf_base_proto_rawDescGZIP(), []int{2} +} + +func (x *S3) GetEndPoint() string { + if x != nil { + return x.EndPoint + } + return "" +} + +func (x *S3) GetAccessKey() string { + if x != nil { + return x.AccessKey + } + return "" +} + +func (x *S3) GetSecretKey() string { + if x != nil { + return x.SecretKey + } + return "" +} + +func (x *S3) GetUseSsl() bool { + if x != nil { + return x.UseSsl + } + return false +} + type MQ struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Driver string `protobuf:"bytes,1,opt,name=driver,proto3" json:"driver,omitempty"` - Database *Database `protobuf:"bytes,2,opt,name=database,proto3" json:"database,omitempty"` + Driver string `protobuf:"bytes,1,opt,name=driver,proto3" json:"driver,omitempty"` } func (x *MQ) Reset() { *x = MQ{} if protoimpl.UnsafeEnabled { - mi := &file_conf_base_proto_msgTypes[2] + mi := &file_conf_base_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -204,7 +274,7 @@ func (x *MQ) String() string { func (*MQ) ProtoMessage() {} func (x *MQ) ProtoReflect() protoreflect.Message { - mi := &file_conf_base_proto_msgTypes[2] + mi := &file_conf_base_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -217,7 +287,7 @@ func (x *MQ) ProtoReflect() protoreflect.Message { // Deprecated: Use MQ.ProtoReflect.Descriptor instead. func (*MQ) Descriptor() ([]byte, []int) { - return file_conf_base_proto_rawDescGZIP(), []int{2} + return file_conf_base_proto_rawDescGZIP(), []int{3} } func (x *MQ) GetDriver() string { @@ -227,13 +297,6 @@ func (x *MQ) GetDriver() string { return "" } -func (x *MQ) GetDatabase() *Database { - if x != nil { - return x.Database - } - return nil -} - type Auth struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -247,7 +310,7 @@ type Auth struct { func (x *Auth) Reset() { *x = Auth{} if protoimpl.UnsafeEnabled { - mi := &file_conf_base_proto_msgTypes[3] + mi := &file_conf_base_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -260,7 +323,7 @@ func (x *Auth) String() string { func (*Auth) ProtoMessage() {} func (x *Auth) ProtoReflect() protoreflect.Message { - mi := &file_conf_base_proto_msgTypes[3] + mi := &file_conf_base_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -273,7 +336,7 @@ func (x *Auth) ProtoReflect() protoreflect.Message { // Deprecated: Use Auth.ProtoReflect.Descriptor instead. func (*Auth) Descriptor() ([]byte, []int) { - return file_conf_base_proto_rawDescGZIP(), []int{3} + return file_conf_base_proto_rawDescGZIP(), []int{4} } func (x *Auth) GetPasswordSalt() string { @@ -302,13 +365,17 @@ type Cache struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Driver string `protobuf:"bytes,1,opt,name=driver,proto3" json:"driver,omitempty"` + Driver string `protobuf:"bytes,1,opt,name=driver,proto3" json:"driver,omitempty"` + Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` + Db int64 `protobuf:"varint,3,opt,name=db,proto3" json:"db,omitempty"` + User string `protobuf:"bytes,4,opt,name=user,proto3" json:"user,omitempty"` + Password string `protobuf:"bytes,5,opt,name=password,proto3" json:"password,omitempty"` } func (x *Cache) Reset() { *x = Cache{} if protoimpl.UnsafeEnabled { - mi := &file_conf_base_proto_msgTypes[4] + mi := &file_conf_base_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -321,7 +388,7 @@ func (x *Cache) String() string { func (*Cache) ProtoMessage() {} func (x *Cache) ProtoReflect() protoreflect.Message { - mi := &file_conf_base_proto_msgTypes[4] + mi := &file_conf_base_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -334,7 +401,7 @@ func (x *Cache) ProtoReflect() protoreflect.Message { // Deprecated: Use Cache.ProtoReflect.Descriptor instead. func (*Cache) Descriptor() ([]byte, []int) { - return file_conf_base_proto_rawDescGZIP(), []int{4} + return file_conf_base_proto_rawDescGZIP(), []int{5} } func (x *Cache) GetDriver() string { @@ -344,6 +411,34 @@ func (x *Cache) GetDriver() string { return "" } +func (x *Cache) GetAddr() string { + if x != nil { + return x.Addr + } + return "" +} + +func (x *Cache) GetDb() int64 { + if x != nil { + return x.Db + } + return 0 +} + +func (x *Cache) GetUser() string { + if x != nil { + return x.User + } + return "" +} + +func (x *Cache) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + type Consul struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -356,7 +451,7 @@ type Consul struct { func (x *Consul) Reset() { *x = Consul{} if protoimpl.UnsafeEnabled { - mi := &file_conf_base_proto_msgTypes[5] + mi := &file_conf_base_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -369,7 +464,7 @@ func (x *Consul) String() string { func (*Consul) ProtoMessage() {} func (x *Consul) ProtoReflect() protoreflect.Message { - mi := &file_conf_base_proto_msgTypes[5] + mi := &file_conf_base_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -382,7 +477,7 @@ func (x *Consul) ProtoReflect() protoreflect.Message { // Deprecated: Use Consul.ProtoReflect.Descriptor instead. func (*Consul) Descriptor() ([]byte, []int) { - return file_conf_base_proto_rawDescGZIP(), []int{5} + return file_conf_base_proto_rawDescGZIP(), []int{6} } func (x *Consul) GetAddr() string { @@ -411,7 +506,7 @@ type Sentry struct { func (x *Sentry) Reset() { *x = Sentry{} if protoimpl.UnsafeEnabled { - mi := &file_conf_base_proto_msgTypes[6] + mi := &file_conf_base_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -424,7 +519,7 @@ func (x *Sentry) String() string { func (*Sentry) ProtoMessage() {} func (x *Sentry) ProtoReflect() protoreflect.Message { - mi := &file_conf_base_proto_msgTypes[6] + mi := &file_conf_base_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -437,7 +532,7 @@ func (x *Sentry) ProtoReflect() protoreflect.Message { // Deprecated: Use Sentry.ProtoReflect.Descriptor instead. func (*Sentry) Descriptor() ([]byte, []int) { - return file_conf_base_proto_rawDescGZIP(), []int{6} + return file_conf_base_proto_rawDescGZIP(), []int{7} } func (x *Sentry) GetDsn() string { @@ -478,30 +573,40 @@ var file_conf_base_proto_rawDesc = []byte{ 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x6e, 0x6f, 0x5f, 0x73, 0x73, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6e, - 0x6f, 0x53, 0x73, 0x6c, 0x22, 0x4e, 0x0a, 0x02, 0x4d, 0x51, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x72, - 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x72, 0x69, 0x76, - 0x65, 0x72, 0x12, 0x30, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, - 0x62, 0x61, 0x73, 0x65, 0x22, 0x69, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, 0x23, 0x0a, 0x0d, - 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x73, 0x61, 0x6c, 0x74, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x53, 0x61, 0x6c, - 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6a, 0x77, 0x74, 0x5f, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6a, 0x77, 0x74, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, - 0x12, 0x1d, 0x0a, 0x0a, 0x6a, 0x77, 0x74, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6a, 0x77, 0x74, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x22, - 0x1f, 0x0a, 0x05, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x72, 0x69, 0x76, - 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, - 0x22, 0x32, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, - 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x14, - 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, - 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x3c, 0x0a, 0x06, 0x53, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x03, 0x64, 0x73, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x73, 0x6e, - 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, - 0x6e, 0x74, 0x42, 0x1e, 0x5a, 0x1c, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, - 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x53, 0x73, 0x6c, 0x22, 0x78, 0x0a, 0x02, 0x53, 0x33, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x6e, + 0x64, 0x5f, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, + 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x73, + 0x73, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, + 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x63, 0x72, + 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x5f, 0x73, 0x73, 0x6c, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x75, 0x73, 0x65, 0x53, 0x73, 0x6c, 0x22, 0x1c, + 0x0a, 0x02, 0x4d, 0x51, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x22, 0x69, 0x0a, 0x04, + 0x41, 0x75, 0x74, 0x68, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, + 0x5f, 0x73, 0x61, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x61, 0x73, + 0x73, 0x77, 0x6f, 0x72, 0x64, 0x53, 0x61, 0x6c, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6a, 0x77, 0x74, + 0x5f, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6a, + 0x77, 0x74, 0x49, 0x73, 0x73, 0x75, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x6a, 0x77, 0x74, 0x5f, + 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6a, 0x77, + 0x74, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x22, 0x73, 0x0a, 0x05, 0x43, 0x61, 0x63, 0x68, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x0e, 0x0a, 0x02, + 0x64, 0x62, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x64, 0x62, 0x12, 0x12, 0x0a, 0x04, + 0x75, 0x73, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, + 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x32, 0x0a, 0x06, + 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, + 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, + 0x22, 0x3c, 0x0a, 0x06, 0x53, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x73, + 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x73, 0x6e, 0x12, 0x20, 0x0a, 0x0b, + 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x1e, + 0x5a, 0x1c, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -516,25 +621,25 @@ func file_conf_base_proto_rawDescGZIP() []byte { return file_conf_base_proto_rawDescData } -var file_conf_base_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_conf_base_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_conf_base_proto_goTypes = []interface{}{ (*GRPC)(nil), // 0: kratos.api.GRPC (*Database)(nil), // 1: kratos.api.Database - (*MQ)(nil), // 2: kratos.api.MQ - (*Auth)(nil), // 3: kratos.api.Auth - (*Cache)(nil), // 4: kratos.api.Cache - (*Consul)(nil), // 5: kratos.api.Consul - (*Sentry)(nil), // 6: kratos.api.Sentry - (*durationpb.Duration)(nil), // 7: google.protobuf.Duration + (*S3)(nil), // 2: kratos.api.S3 + (*MQ)(nil), // 3: kratos.api.MQ + (*Auth)(nil), // 4: kratos.api.Auth + (*Cache)(nil), // 5: kratos.api.Cache + (*Consul)(nil), // 6: kratos.api.Consul + (*Sentry)(nil), // 7: kratos.api.Sentry + (*durationpb.Duration)(nil), // 8: google.protobuf.Duration } var file_conf_base_proto_depIdxs = []int32{ - 7, // 0: kratos.api.GRPC.timeout:type_name -> google.protobuf.Duration - 1, // 1: kratos.api.MQ.database:type_name -> kratos.api.Database - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 8, // 0: kratos.api.GRPC.timeout:type_name -> google.protobuf.Duration + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_conf_base_proto_init() } @@ -568,7 +673,7 @@ func file_conf_base_proto_init() { } } file_conf_base_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MQ); i { + switch v := v.(*S3); i { case 0: return &v.state case 1: @@ -580,7 +685,7 @@ func file_conf_base_proto_init() { } } file_conf_base_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Auth); i { + switch v := v.(*MQ); i { case 0: return &v.state case 1: @@ -592,7 +697,7 @@ func file_conf_base_proto_init() { } } file_conf_base_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Cache); i { + switch v := v.(*Auth); i { case 0: return &v.state case 1: @@ -604,7 +709,7 @@ func file_conf_base_proto_init() { } } file_conf_base_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Consul); i { + switch v := v.(*Cache); i { case 0: return &v.state case 1: @@ -616,6 +721,18 @@ func file_conf_base_proto_init() { } } file_conf_base_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Consul); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_conf_base_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Sentry); i { case 0: return &v.state @@ -634,7 +751,7 @@ func file_conf_base_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_conf_base_proto_rawDesc, NumEnums: 0, - NumMessages: 7, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/conf/base.proto b/internal/conf/base.proto index 18a1d09d..0befbd5e 100644 --- a/internal/conf/base.proto +++ b/internal/conf/base.proto @@ -21,9 +21,15 @@ message Database { bool no_ssl = 7; } +message S3 { + string end_point = 1; + string access_key = 2; + string secret_key = 3; + bool use_ssl = 4; +} + message MQ { string driver = 1; - Database database = 2; } message Auth { @@ -34,6 +40,10 @@ message Auth { message Cache { string driver = 1; + string addr = 2; + int64 db = 3; + string user = 4; + string password = 5; } message Consul { diff --git a/internal/conf/librarian.pb.go b/internal/conf/librarian.pb.go index 1b2daafd..87598f19 100644 --- a/internal/conf/librarian.pb.go +++ b/internal/conf/librarian.pb.go @@ -27,13 +27,14 @@ type Librarian struct { EnableServiceDiscovery *Librarian_EnableServiceDiscovery `protobuf:"bytes,10,opt,name=enable_service_discovery,json=enableServiceDiscovery,proto3" json:"enable_service_discovery,omitempty"` Server *SephirahServer `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"` - Data *SephirahData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - Auth *Auth `protobuf:"bytes,3,opt,name=auth,proto3" json:"auth,omitempty"` - Mq *MQ `protobuf:"bytes,4,opt,name=mq,proto3" json:"mq,omitempty"` - Cache *Cache `protobuf:"bytes,5,opt,name=cache,proto3" json:"cache,omitempty"` - Porter *Porter `protobuf:"bytes,6,opt,name=porter,proto3" json:"porter,omitempty"` - Consul *Consul `protobuf:"bytes,7,opt,name=consul,proto3" json:"consul,omitempty"` - Sentry *Sentry `protobuf:"bytes,8,opt,name=sentry,proto3" json:"sentry,omitempty"` + Database *Database `protobuf:"bytes,2,opt,name=database,proto3" json:"database,omitempty"` + S3 *S3 `protobuf:"bytes,3,opt,name=s3,proto3" json:"s3,omitempty"` + Auth *Auth `protobuf:"bytes,4,opt,name=auth,proto3" json:"auth,omitempty"` + Mq *MQ `protobuf:"bytes,5,opt,name=mq,proto3" json:"mq,omitempty"` + Cache *Cache `protobuf:"bytes,6,opt,name=cache,proto3" json:"cache,omitempty"` + Porter *Porter `protobuf:"bytes,7,opt,name=porter,proto3" json:"porter,omitempty"` + Consul *Consul `protobuf:"bytes,8,opt,name=consul,proto3" json:"consul,omitempty"` + Sentry *Sentry `protobuf:"bytes,9,opt,name=sentry,proto3" json:"sentry,omitempty"` Mapper *Mapper `protobuf:"bytes,11,opt,name=mapper,proto3" json:"mapper,omitempty"` Searcher *Searcher `protobuf:"bytes,12,opt,name=searcher,proto3" json:"searcher,omitempty"` Miner *Miner `protobuf:"bytes,13,opt,name=miner,proto3" json:"miner,omitempty"` @@ -85,9 +86,16 @@ func (x *Librarian) GetServer() *SephirahServer { return nil } -func (x *Librarian) GetData() *SephirahData { +func (x *Librarian) GetDatabase() *Database { if x != nil { - return x.Data + return x.Database + } + return nil +} + +func (x *Librarian) GetS3() *S3 { + if x != nil { + return x.S3 } return nil } @@ -237,7 +245,7 @@ var file_conf_librarian_proto_rawDesc = []byte{ 0x61, 0x70, 0x70, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x13, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x10, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0xcb, 0x05, 0x0a, 0x09, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, + 0x74, 0x6f, 0x22, 0xef, 0x05, 0x0a, 0x09, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x12, 0x66, 0x0a, 0x18, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x64, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, @@ -247,44 +255,46 @@ var file_conf_librarian_proto_rawDesc = []byte{ 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x12, 0x32, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x04, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6b, 0x72, 0x61, - 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, - 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x24, 0x0a, 0x04, 0x61, 0x75, - 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, - 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x04, 0x61, 0x75, 0x74, 0x68, - 0x12, 0x1e, 0x0a, 0x02, 0x6d, 0x71, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6b, - 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x51, 0x52, 0x02, 0x6d, 0x71, - 0x12, 0x27, 0x0a, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x11, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x63, - 0x68, 0x65, 0x52, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x70, 0x6f, 0x72, - 0x74, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, - 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x52, 0x06, 0x70, - 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x75, - 0x6c, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, - 0x65, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x2a, 0x0a, - 0x06, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, - 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x61, 0x70, 0x70, 0x65, - 0x72, 0x52, 0x06, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x08, 0x73, 0x65, 0x61, - 0x72, 0x63, 0x68, 0x65, 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6b, 0x72, - 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x65, - 0x72, 0x52, 0x08, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x05, 0x6d, - 0x69, 0x6e, 0x65, 0x72, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6b, 0x72, 0x61, - 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x69, 0x6e, 0x65, 0x72, 0x52, 0x05, 0x6d, - 0x69, 0x6e, 0x65, 0x72, 0x1a, 0x7a, 0x0a, 0x16, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x12, 0x16, - 0x0a, 0x06, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, - 0x6d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x69, - 0x6e, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6d, 0x69, 0x6e, 0x65, 0x72, - 0x42, 0x1e, 0x5a, 0x1c, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, 0x66, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x08, + 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, + 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x44, 0x61, 0x74, 0x61, + 0x62, 0x61, 0x73, 0x65, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x1e, + 0x0a, 0x02, 0x73, 0x33, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6b, 0x72, 0x61, + 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x33, 0x52, 0x02, 0x73, 0x33, 0x12, 0x24, + 0x0a, 0x04, 0x61, 0x75, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, + 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x04, + 0x61, 0x75, 0x74, 0x68, 0x12, 0x1e, 0x0a, 0x02, 0x6d, 0x71, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x0e, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x51, + 0x52, 0x02, 0x6d, 0x71, 0x12, 0x27, 0x0a, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x12, 0x2a, 0x0a, + 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, + 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x65, + 0x72, 0x52, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x06, 0x63, 0x6f, 0x6e, + 0x73, 0x75, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, + 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x52, 0x06, 0x63, + 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x53, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x2a, 0x0a, 0x06, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, + 0x61, 0x70, 0x70, 0x65, 0x72, 0x52, 0x06, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x12, 0x30, 0x0a, + 0x08, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x14, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x61, + 0x72, 0x63, 0x68, 0x65, 0x72, 0x52, 0x08, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x12, + 0x27, 0x0a, 0x05, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, + 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x69, 0x6e, 0x65, + 0x72, 0x52, 0x05, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x1a, 0x7a, 0x0a, 0x16, 0x45, 0x6e, 0x61, 0x62, + 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, + 0x72, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x06, 0x6d, 0x61, 0x70, 0x70, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x73, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x14, + 0x0a, 0x05, 0x6d, 0x69, 0x6e, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x6d, + 0x69, 0x6e, 0x65, 0x72, 0x42, 0x1e, 0x5a, 0x1c, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, + 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, + 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -304,35 +314,37 @@ var file_conf_librarian_proto_goTypes = []interface{}{ (*Librarian)(nil), // 0: kratos.api.Librarian (*Librarian_EnableServiceDiscovery)(nil), // 1: kratos.api.Librarian.EnableServiceDiscovery (*SephirahServer)(nil), // 2: kratos.api.SephirahServer - (*SephirahData)(nil), // 3: kratos.api.SephirahData - (*Auth)(nil), // 4: kratos.api.Auth - (*MQ)(nil), // 5: kratos.api.MQ - (*Cache)(nil), // 6: kratos.api.Cache - (*Porter)(nil), // 7: kratos.api.Porter - (*Consul)(nil), // 8: kratos.api.Consul - (*Sentry)(nil), // 9: kratos.api.Sentry - (*Mapper)(nil), // 10: kratos.api.Mapper - (*Searcher)(nil), // 11: kratos.api.Searcher - (*Miner)(nil), // 12: kratos.api.Miner + (*Database)(nil), // 3: kratos.api.Database + (*S3)(nil), // 4: kratos.api.S3 + (*Auth)(nil), // 5: kratos.api.Auth + (*MQ)(nil), // 6: kratos.api.MQ + (*Cache)(nil), // 7: kratos.api.Cache + (*Porter)(nil), // 8: kratos.api.Porter + (*Consul)(nil), // 9: kratos.api.Consul + (*Sentry)(nil), // 10: kratos.api.Sentry + (*Mapper)(nil), // 11: kratos.api.Mapper + (*Searcher)(nil), // 12: kratos.api.Searcher + (*Miner)(nil), // 13: kratos.api.Miner } var file_conf_librarian_proto_depIdxs = []int32{ 1, // 0: kratos.api.Librarian.enable_service_discovery:type_name -> kratos.api.Librarian.EnableServiceDiscovery 2, // 1: kratos.api.Librarian.server:type_name -> kratos.api.SephirahServer - 3, // 2: kratos.api.Librarian.data:type_name -> kratos.api.SephirahData - 4, // 3: kratos.api.Librarian.auth:type_name -> kratos.api.Auth - 5, // 4: kratos.api.Librarian.mq:type_name -> kratos.api.MQ - 6, // 5: kratos.api.Librarian.cache:type_name -> kratos.api.Cache - 7, // 6: kratos.api.Librarian.porter:type_name -> kratos.api.Porter - 8, // 7: kratos.api.Librarian.consul:type_name -> kratos.api.Consul - 9, // 8: kratos.api.Librarian.sentry:type_name -> kratos.api.Sentry - 10, // 9: kratos.api.Librarian.mapper:type_name -> kratos.api.Mapper - 11, // 10: kratos.api.Librarian.searcher:type_name -> kratos.api.Searcher - 12, // 11: kratos.api.Librarian.miner:type_name -> kratos.api.Miner - 12, // [12:12] is the sub-list for method output_type - 12, // [12:12] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 3, // 2: kratos.api.Librarian.database:type_name -> kratos.api.Database + 4, // 3: kratos.api.Librarian.s3:type_name -> kratos.api.S3 + 5, // 4: kratos.api.Librarian.auth:type_name -> kratos.api.Auth + 6, // 5: kratos.api.Librarian.mq:type_name -> kratos.api.MQ + 7, // 6: kratos.api.Librarian.cache:type_name -> kratos.api.Cache + 8, // 7: kratos.api.Librarian.porter:type_name -> kratos.api.Porter + 9, // 8: kratos.api.Librarian.consul:type_name -> kratos.api.Consul + 10, // 9: kratos.api.Librarian.sentry:type_name -> kratos.api.Sentry + 11, // 10: kratos.api.Librarian.mapper:type_name -> kratos.api.Mapper + 12, // 11: kratos.api.Librarian.searcher:type_name -> kratos.api.Searcher + 13, // 12: kratos.api.Librarian.miner:type_name -> kratos.api.Miner + 13, // [13:13] is the sub-list for method output_type + 13, // [13:13] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name } func init() { file_conf_librarian_proto_init() } diff --git a/internal/conf/librarian.proto b/internal/conf/librarian.proto index 72800059..ef0039d8 100644 --- a/internal/conf/librarian.proto +++ b/internal/conf/librarian.proto @@ -19,13 +19,14 @@ message Librarian { EnableServiceDiscovery enable_service_discovery = 10; SephirahServer server = 1; - SephirahData data = 2; - Auth auth = 3; - MQ mq = 4; - Cache cache = 5; - Porter porter = 6; - Consul consul = 7; - Sentry sentry = 8; + Database database = 2; + S3 s3 = 3; + Auth auth = 4; + MQ mq = 5; + Cache cache = 6; + Porter porter = 7; + Consul consul = 8; + Sentry sentry = 9; Mapper mapper = 11; Searcher searcher = 12; diff --git a/internal/conf/sephirah.pb.go b/internal/conf/sephirah.pb.go index 671e484a..9c4e3e34 100644 --- a/internal/conf/sephirah.pb.go +++ b/internal/conf/sephirah.pb.go @@ -83,61 +83,6 @@ func (x *SephirahServer) GetInfo() *SephirahServer_Info { return nil } -type SephirahData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Database *Database `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"` - S3 *SephirahData_S3 `protobuf:"bytes,2,opt,name=s3,proto3" json:"s3,omitempty"` -} - -func (x *SephirahData) Reset() { - *x = SephirahData{} - if protoimpl.UnsafeEnabled { - mi := &file_conf_sephirah_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SephirahData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SephirahData) ProtoMessage() {} - -func (x *SephirahData) ProtoReflect() protoreflect.Message { - mi := &file_conf_sephirah_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SephirahData.ProtoReflect.Descriptor instead. -func (*SephirahData) Descriptor() ([]byte, []int) { - return file_conf_sephirah_proto_rawDescGZIP(), []int{1} -} - -func (x *SephirahData) GetDatabase() *Database { - if x != nil { - return x.Database - } - return nil -} - -func (x *SephirahData) GetS3() *SephirahData_S3 { - if x != nil { - return x.S3 - } - return nil -} - type Porter struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -149,7 +94,7 @@ type Porter struct { func (x *Porter) Reset() { *x = Porter{} if protoimpl.UnsafeEnabled { - mi := &file_conf_sephirah_proto_msgTypes[2] + mi := &file_conf_sephirah_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -162,7 +107,7 @@ func (x *Porter) String() string { func (*Porter) ProtoMessage() {} func (x *Porter) ProtoReflect() protoreflect.Message { - mi := &file_conf_sephirah_proto_msgTypes[2] + mi := &file_conf_sephirah_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -175,7 +120,7 @@ func (x *Porter) ProtoReflect() protoreflect.Message { // Deprecated: Use Porter.ProtoReflect.Descriptor instead. func (*Porter) Descriptor() ([]byte, []int) { - return file_conf_sephirah_proto_rawDescGZIP(), []int{2} + return file_conf_sephirah_proto_rawDescGZIP(), []int{1} } func (x *Porter) GetTrustedAddress() []string { @@ -190,20 +135,21 @@ type Sephirah struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Server *SephirahServer `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"` - Data *SephirahData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - Auth *Auth `protobuf:"bytes,3,opt,name=auth,proto3" json:"auth,omitempty"` - Mq *MQ `protobuf:"bytes,4,opt,name=mq,proto3" json:"mq,omitempty"` - Cache *Cache `protobuf:"bytes,5,opt,name=cache,proto3" json:"cache,omitempty"` - Porter *Porter `protobuf:"bytes,6,opt,name=porter,proto3" json:"porter,omitempty"` - Consul *Consul `protobuf:"bytes,7,opt,name=consul,proto3" json:"consul,omitempty"` - Sentry *Sentry `protobuf:"bytes,8,opt,name=sentry,proto3" json:"sentry,omitempty"` + Server *SephirahServer `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"` + Database *Database `protobuf:"bytes,2,opt,name=database,proto3" json:"database,omitempty"` + S3 *S3 `protobuf:"bytes,3,opt,name=s3,proto3" json:"s3,omitempty"` + Auth *Auth `protobuf:"bytes,4,opt,name=auth,proto3" json:"auth,omitempty"` + Mq *MQ `protobuf:"bytes,5,opt,name=mq,proto3" json:"mq,omitempty"` + Cache *Cache `protobuf:"bytes,6,opt,name=cache,proto3" json:"cache,omitempty"` + Porter *Porter `protobuf:"bytes,7,opt,name=porter,proto3" json:"porter,omitempty"` + Consul *Consul `protobuf:"bytes,8,opt,name=consul,proto3" json:"consul,omitempty"` + Sentry *Sentry `protobuf:"bytes,9,opt,name=sentry,proto3" json:"sentry,omitempty"` } func (x *Sephirah) Reset() { *x = Sephirah{} if protoimpl.UnsafeEnabled { - mi := &file_conf_sephirah_proto_msgTypes[3] + mi := &file_conf_sephirah_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -216,7 +162,7 @@ func (x *Sephirah) String() string { func (*Sephirah) ProtoMessage() {} func (x *Sephirah) ProtoReflect() protoreflect.Message { - mi := &file_conf_sephirah_proto_msgTypes[3] + mi := &file_conf_sephirah_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -229,7 +175,7 @@ func (x *Sephirah) ProtoReflect() protoreflect.Message { // Deprecated: Use Sephirah.ProtoReflect.Descriptor instead. func (*Sephirah) Descriptor() ([]byte, []int) { - return file_conf_sephirah_proto_rawDescGZIP(), []int{3} + return file_conf_sephirah_proto_rawDescGZIP(), []int{2} } func (x *Sephirah) GetServer() *SephirahServer { @@ -239,9 +185,16 @@ func (x *Sephirah) GetServer() *SephirahServer { return nil } -func (x *Sephirah) GetData() *SephirahData { +func (x *Sephirah) GetDatabase() *Database { if x != nil { - return x.Data + return x.Database + } + return nil +} + +func (x *Sephirah) GetS3() *S3 { + if x != nil { + return x.S3 } return nil } @@ -303,7 +256,7 @@ type SephirahServer_Info struct { func (x *SephirahServer_Info) Reset() { *x = SephirahServer_Info{} if protoimpl.UnsafeEnabled { - mi := &file_conf_sephirah_proto_msgTypes[4] + mi := &file_conf_sephirah_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -316,7 +269,7 @@ func (x *SephirahServer_Info) String() string { func (*SephirahServer_Info) ProtoMessage() {} func (x *SephirahServer_Info) ProtoReflect() protoreflect.Message { - mi := &file_conf_sephirah_proto_msgTypes[4] + mi := &file_conf_sephirah_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -367,77 +320,6 @@ func (x *SephirahServer_Info) GetBackgroundUrl() string { return "" } -type SephirahData_S3 struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - EndPoint string `protobuf:"bytes,1,opt,name=end_point,json=endPoint,proto3" json:"end_point,omitempty"` - AccessKey string `protobuf:"bytes,2,opt,name=access_key,json=accessKey,proto3" json:"access_key,omitempty"` - SecretKey string `protobuf:"bytes,3,opt,name=secret_key,json=secretKey,proto3" json:"secret_key,omitempty"` - UseSsl bool `protobuf:"varint,4,opt,name=use_ssl,json=useSsl,proto3" json:"use_ssl,omitempty"` -} - -func (x *SephirahData_S3) Reset() { - *x = SephirahData_S3{} - if protoimpl.UnsafeEnabled { - mi := &file_conf_sephirah_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SephirahData_S3) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SephirahData_S3) ProtoMessage() {} - -func (x *SephirahData_S3) ProtoReflect() protoreflect.Message { - mi := &file_conf_sephirah_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SephirahData_S3.ProtoReflect.Descriptor instead. -func (*SephirahData_S3) Descriptor() ([]byte, []int) { - return file_conf_sephirah_proto_rawDescGZIP(), []int{1, 0} -} - -func (x *SephirahData_S3) GetEndPoint() string { - if x != nil { - return x.EndPoint - } - return "" -} - -func (x *SephirahData_S3) GetAccessKey() string { - if x != nil { - return x.AccessKey - } - return "" -} - -func (x *SephirahData_S3) GetSecretKey() string { - if x != nil { - return x.SecretKey - } - return "" -} - -func (x *SephirahData_S3) GetUseSsl() bool { - if x != nil { - return x.UseSsl - } - return false -} - var File_conf_sephirah_proto protoreflect.FileDescriptor var file_conf_sephirah_proto_rawDesc = []byte{ @@ -464,49 +346,36 @@ var file_conf_sephirah_proto_rawDesc = []byte{ 0x07, 0x6c, 0x6f, 0x67, 0x6f, 0x55, 0x72, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x72, 0x6c, 0x22, - 0xe7, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x44, 0x61, 0x74, 0x61, - 0x12, 0x30, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, - 0x73, 0x65, 0x12, 0x2b, 0x0a, 0x02, 0x73, 0x33, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, - 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, - 0x69, 0x72, 0x61, 0x68, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x53, 0x33, 0x52, 0x02, 0x73, 0x33, 0x1a, - 0x78, 0x0a, 0x02, 0x53, 0x33, 0x12, 0x1b, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x69, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, - 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6b, 0x65, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, - 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, - 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x5f, 0x73, 0x73, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x06, 0x75, 0x73, 0x65, 0x53, 0x73, 0x6c, 0x22, 0x31, 0x0a, 0x06, 0x50, 0x6f, 0x72, - 0x74, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x5f, 0x61, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x72, - 0x75, 0x73, 0x74, 0x65, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0xdf, 0x02, 0x0a, - 0x08, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x12, 0x32, 0x0a, 0x06, 0x73, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x6b, 0x72, 0x61, 0x74, - 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x2c, 0x0a, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6b, 0x72, - 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, - 0x68, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x24, 0x0a, 0x04, 0x61, - 0x75, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, - 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x04, 0x61, 0x75, 0x74, - 0x68, 0x12, 0x1e, 0x0a, 0x02, 0x6d, 0x71, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, - 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x51, 0x52, 0x02, 0x6d, - 0x71, 0x12, 0x27, 0x0a, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x11, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, - 0x63, 0x68, 0x65, 0x52, 0x05, 0x63, 0x61, 0x63, 0x68, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x70, 0x6f, - 0x72, 0x74, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, - 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x52, 0x06, - 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x2a, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x73, - 0x75, 0x6c, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x53, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x42, 0x1e, - 0x5a, 0x1c, 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x31, 0x0a, 0x06, 0x50, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x12, 0x27, 0x0a, 0x0f, 0x74, 0x72, 0x75, + 0x73, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x0e, 0x74, 0x72, 0x75, 0x73, 0x74, 0x65, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x22, 0x83, 0x03, 0x0a, 0x08, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x12, + 0x32, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1a, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, + 0x68, 0x69, 0x72, 0x61, 0x68, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x12, 0x30, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x08, 0x64, 0x61, 0x74, + 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x1e, 0x0a, 0x02, 0x73, 0x33, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0e, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, + 0x33, 0x52, 0x02, 0x73, 0x33, 0x12, 0x24, 0x0a, 0x04, 0x61, 0x75, 0x74, 0x68, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x41, 0x75, 0x74, 0x68, 0x52, 0x04, 0x61, 0x75, 0x74, 0x68, 0x12, 0x1e, 0x0a, 0x02, 0x6d, + 0x71, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4d, 0x51, 0x52, 0x02, 0x6d, 0x71, 0x12, 0x27, 0x0a, 0x05, 0x63, + 0x61, 0x63, 0x68, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x6b, 0x72, 0x61, + 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x52, 0x05, 0x63, + 0x61, 0x63, 0x68, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x52, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, + 0x12, 0x2a, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x12, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x43, 0x6f, + 0x6e, 0x73, 0x75, 0x6c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x12, 0x2a, 0x0a, 0x06, + 0x73, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x6b, + 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x06, 0x73, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x42, 0x1e, 0x5a, 0x1c, 0x4c, 0x69, 0x62, 0x72, + 0x61, 0x72, 0x69, 0x61, 0x6e, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x63, + 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -521,41 +390,39 @@ func file_conf_sephirah_proto_rawDescGZIP() []byte { return file_conf_sephirah_proto_rawDescData } -var file_conf_sephirah_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_conf_sephirah_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_conf_sephirah_proto_goTypes = []interface{}{ (*SephirahServer)(nil), // 0: kratos.api.SephirahServer - (*SephirahData)(nil), // 1: kratos.api.SephirahData - (*Porter)(nil), // 2: kratos.api.Porter - (*Sephirah)(nil), // 3: kratos.api.Sephirah - (*SephirahServer_Info)(nil), // 4: kratos.api.SephirahServer.Info - (*SephirahData_S3)(nil), // 5: kratos.api.SephirahData.S3 - (*GRPC)(nil), // 6: kratos.api.GRPC - (*Database)(nil), // 7: kratos.api.Database - (*Auth)(nil), // 8: kratos.api.Auth - (*MQ)(nil), // 9: kratos.api.MQ - (*Cache)(nil), // 10: kratos.api.Cache - (*Consul)(nil), // 11: kratos.api.Consul - (*Sentry)(nil), // 12: kratos.api.Sentry + (*Porter)(nil), // 1: kratos.api.Porter + (*Sephirah)(nil), // 2: kratos.api.Sephirah + (*SephirahServer_Info)(nil), // 3: kratos.api.SephirahServer.Info + (*GRPC)(nil), // 4: kratos.api.GRPC + (*Database)(nil), // 5: kratos.api.Database + (*S3)(nil), // 6: kratos.api.S3 + (*Auth)(nil), // 7: kratos.api.Auth + (*MQ)(nil), // 8: kratos.api.MQ + (*Cache)(nil), // 9: kratos.api.Cache + (*Consul)(nil), // 10: kratos.api.Consul + (*Sentry)(nil), // 11: kratos.api.Sentry } var file_conf_sephirah_proto_depIdxs = []int32{ - 6, // 0: kratos.api.SephirahServer.grpc:type_name -> kratos.api.GRPC - 6, // 1: kratos.api.SephirahServer.grpc_web:type_name -> kratos.api.GRPC - 4, // 2: kratos.api.SephirahServer.info:type_name -> kratos.api.SephirahServer.Info - 7, // 3: kratos.api.SephirahData.database:type_name -> kratos.api.Database - 5, // 4: kratos.api.SephirahData.s3:type_name -> kratos.api.SephirahData.S3 - 0, // 5: kratos.api.Sephirah.server:type_name -> kratos.api.SephirahServer - 1, // 6: kratos.api.Sephirah.data:type_name -> kratos.api.SephirahData - 8, // 7: kratos.api.Sephirah.auth:type_name -> kratos.api.Auth - 9, // 8: kratos.api.Sephirah.mq:type_name -> kratos.api.MQ - 10, // 9: kratos.api.Sephirah.cache:type_name -> kratos.api.Cache - 2, // 10: kratos.api.Sephirah.porter:type_name -> kratos.api.Porter - 11, // 11: kratos.api.Sephirah.consul:type_name -> kratos.api.Consul - 12, // 12: kratos.api.Sephirah.sentry:type_name -> kratos.api.Sentry - 13, // [13:13] is the sub-list for method output_type - 13, // [13:13] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 4, // 0: kratos.api.SephirahServer.grpc:type_name -> kratos.api.GRPC + 4, // 1: kratos.api.SephirahServer.grpc_web:type_name -> kratos.api.GRPC + 3, // 2: kratos.api.SephirahServer.info:type_name -> kratos.api.SephirahServer.Info + 0, // 3: kratos.api.Sephirah.server:type_name -> kratos.api.SephirahServer + 5, // 4: kratos.api.Sephirah.database:type_name -> kratos.api.Database + 6, // 5: kratos.api.Sephirah.s3:type_name -> kratos.api.S3 + 7, // 6: kratos.api.Sephirah.auth:type_name -> kratos.api.Auth + 8, // 7: kratos.api.Sephirah.mq:type_name -> kratos.api.MQ + 9, // 8: kratos.api.Sephirah.cache:type_name -> kratos.api.Cache + 1, // 9: kratos.api.Sephirah.porter:type_name -> kratos.api.Porter + 10, // 10: kratos.api.Sephirah.consul:type_name -> kratos.api.Consul + 11, // 11: kratos.api.Sephirah.sentry:type_name -> kratos.api.Sentry + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_conf_sephirah_proto_init() } @@ -578,18 +445,6 @@ func file_conf_sephirah_proto_init() { } } file_conf_sephirah_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SephirahData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_conf_sephirah_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Porter); i { case 0: return &v.state @@ -601,7 +456,7 @@ func file_conf_sephirah_proto_init() { return nil } } - file_conf_sephirah_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_conf_sephirah_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Sephirah); i { case 0: return &v.state @@ -613,7 +468,7 @@ func file_conf_sephirah_proto_init() { return nil } } - file_conf_sephirah_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_conf_sephirah_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SephirahServer_Info); i { case 0: return &v.state @@ -625,18 +480,6 @@ func file_conf_sephirah_proto_init() { return nil } } - file_conf_sephirah_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SephirahData_S3); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -644,7 +487,7 @@ func file_conf_sephirah_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_conf_sephirah_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/conf/sephirah.proto b/internal/conf/sephirah.proto index c8e58d6c..30e61b4a 100644 --- a/internal/conf/sephirah.proto +++ b/internal/conf/sephirah.proto @@ -18,28 +18,18 @@ message SephirahServer { Info info = 3; } -message SephirahData { - message S3 { - string end_point = 1; - string access_key = 2; - string secret_key = 3; - bool use_ssl = 4; - } - Database database = 1; - S3 s3 = 2; -} - message Porter { repeated string trusted_address = 1; } message Sephirah { SephirahServer server = 1; - SephirahData data = 2; - Auth auth = 3; - MQ mq = 4; - Cache cache = 5; - Porter porter = 6; - Consul consul = 7; - Sentry sentry = 8; + Database database = 2; + S3 s3 = 3; + Auth auth = 4; + MQ mq = 5; + Cache cache = 6; + Porter porter = 7; + Consul consul = 8; + Sentry sentry = 9; } diff --git a/internal/lib/libcache/cache.go b/internal/lib/libcache/cache.go index db176b4b..df5d12df 100644 --- a/internal/lib/libcache/cache.go +++ b/internal/lib/libcache/cache.go @@ -27,7 +27,7 @@ func NewStore(c *conf.Cache) (Store, error) { case "memory": res, err = newRistrettoCache() case "redis": - res = newRedisCache() + res = newRedisCache(c) default: return nil, errors.New("unsupported cache driver") } @@ -49,8 +49,11 @@ func newRistrettoCache() (Store, error) { return newRistretto(ristrettoCache), nil } -func newRedisCache() Store { +func newRedisCache(c *conf.Cache) Store { return newRedis(redis.NewClient(&redis.Options{ //nolint:exhaustruct // no need - Addr: "127.0.0.1:6379", + Addr: c.GetAddr(), + DB: int(c.GetDb()), + Username: c.GetUser(), + Password: c.GetPassword(), })) } diff --git a/internal/lib/libmq/mq.go b/internal/lib/libmq/mq.go index 20888615..639b7def 100644 --- a/internal/lib/libmq/mq.go +++ b/internal/lib/libmq/mq.go @@ -29,7 +29,7 @@ type pubSub struct { subscriber message.Subscriber } -func NewMQ(c *conf.MQ, app *libapp.Settings) (*MQ, func(), error) { +func NewMQ(c *conf.MQ, dbc *conf.Database, cachec *conf.Cache, app *libapp.Settings) (*MQ, func(), error) { loggerAdapter := newMQLogger() var ps *pubSub if c == nil { @@ -43,8 +43,20 @@ func NewMQ(c *conf.MQ, app *libapp.Settings) (*MQ, func(), error) { case "memory": ps = newGoChannelAdapter(loggerAdapter) case "sql": + if dbc == nil || dbc.GetDriver() != "postgres" { + return nil, func() {}, errors.New("invalid postgres driver for mq") + } + var err error + ps, err = newSQLAdapter(dbc, loggerAdapter) + if err != nil { + return nil, func() {}, err + } + case "redis": + if cachec == nil || cachec.GetDriver() != "redis" { + return nil, func() {}, errors.New("invalid redis driver for mq") + } var err error - ps, err = newSQLAdapter(c.GetDatabase(), loggerAdapter) + ps, err = newRedisAdapter(cachec, loggerAdapter) if err != nil { return nil, func() {}, err } diff --git a/internal/lib/libmq/mq_redis.go b/internal/lib/libmq/mq_redis.go new file mode 100644 index 00000000..ed518eef --- /dev/null +++ b/internal/lib/libmq/mq_redis.go @@ -0,0 +1,36 @@ +package libmq + +import ( + "github.com/tuihub/librarian/internal/conf" + + "github.com/ThreeDotsLabs/watermill-redisstream/pkg/redisstream" + "github.com/redis/go-redis/v9" +) + +func newRedisAdapter(c *conf.Cache, loggerAdapter *mqLogger) (*pubSub, error) { + client := redis.NewClient(&redis.Options{ //nolint:exhaustruct // no need + Addr: c.GetAddr(), + DB: int(c.GetDb()), + Username: c.GetUser(), + Password: c.GetPassword(), + }) + subScriber, err := redisstream.NewSubscriber( + redisstream.SubscriberConfig{ //nolint:exhaustruct // no need + Client: client, + }, + loggerAdapter, + ) + if err != nil { + return nil, err + } + publisher, err := redisstream.NewPublisher( + redisstream.PublisherConfig{ //nolint:exhaustruct // no need + Client: client, + }, + loggerAdapter, + ) + if err != nil { + return nil, err + } + return &pubSub{publisher, subScriber}, nil +} diff --git a/tests/docker-compose.yaml b/tests/docker-compose.yaml index 18e412e4..cb957eed 100644 --- a/tests/docker-compose.yaml +++ b/tests/docker-compose.yaml @@ -56,4 +56,10 @@ services: ports: - "127.0.0.1:8500:8500" command: "agent -dev -server -client=0.0.0.0 -ui" + restart: unless-stopped + + redis: + image: redis:alpine + ports: + - "127.0.0.1:6379:6379" restart: unless-stopped \ No newline at end of file