From 34c2bc76110e0aa49bcf0356a41c34cf664d513f Mon Sep 17 00:00:00 2001 From: MuZhou233 Date: Wed, 14 Feb 2024 04:29:09 +0000 Subject: [PATCH] feat: support zero config run --- README.md | 4 +- app/searcher/internal/data/data.go | 25 +- app/sephirah/cmd/sephirah/wire.go | 6 +- app/sephirah/cmd/sephirah/wire_gen.go | 14 +- app/sephirah/internal/data/binah.go | 2 +- app/sephirah/internal/data/data.go | 28 +- .../internal/supervisor/supervisor.go | 4 +- app/sephirah/pkg/service/wire.go | 4 +- app/sephirah/pkg/service/wire_gen.go | 10 +- cmd/librarian/main.go | 14 +- cmd/librarian/wire.go | 6 +- cmd/librarian/wire_gen.go | 8 +- configs/example-for-single-node.yaml | 75 ++-- configs/example-for-testing.yaml | 37 +- internal/conf/base.pb.go | 43 ++- internal/conf/base.proto | 4 +- internal/conf/librarian.pb.go | 189 ++++++--- internal/conf/librarian.proto | 19 +- internal/conf/sephirah.pb.go | 361 +++++++++--------- internal/conf/sephirah.proto | 38 +- internal/lib/libapp/app.go | 17 +- .../lib/libapp/inherent_settings_release.go | 2 +- internal/lib/libauth/auth.go | 10 +- internal/lib/libauth/jwt.go | 2 +- internal/lib/libauth/password.go | 2 +- internal/lib/libcache/cache.go | 12 +- internal/lib/libmq/mq.go | 7 + internal/lib/libzap/zap.go | 11 + internal/server/grpc.go | 2 +- internal/server/grpc_web.go | 2 +- 30 files changed, 559 insertions(+), 399 deletions(-) diff --git a/README.md b/README.md index c8fe4e22..cccbb2f9 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ Config file is required. The config template is provided in [configs](configs) ### Command line arguments -- `config` path, required, eg: --conf config.yaml -- `data` path, required, eg: --data /opt/librarian/data +- `config` path, eg: --conf config.yaml +- `data` path, eg: --data /opt/librarian/data ### Environment variables diff --git a/app/searcher/internal/data/data.go b/app/searcher/internal/data/data.go index c5ad675e..27bfd8c7 100644 --- a/app/searcher/internal/data/data.go +++ b/app/searcher/internal/data/data.go @@ -2,10 +2,11 @@ package data import ( "context" - "errors" "time" "github.com/tuihub/librarian/app/searcher/internal/biz" + "github.com/tuihub/librarian/internal/lib/logger" + "github.com/tuihub/librarian/internal/model" "github.com/blevesearch/bleve/v2" "github.com/google/wire" @@ -31,7 +32,22 @@ func NewSearcherRepo( search: b, }, nil } - return nil, errors.New("no valid search backend") + logger.Warnf("no valid search backend, search function will not work") + return &defaultSearcherRepo{sf: sf}, nil +} + +type defaultSearcherRepo struct { + sf *sonyflake.Sonyflake +} + +func (d defaultSearcherRepo) DescribeID( + context.Context, model.InternalID, biz.Index, bool, string) error { + return nil // search disabled +} + +func (d defaultSearcherRepo) SearchID( + context.Context, biz.Index, model.Paging, string) ([]*biz.SearchResult, error) { + return nil, nil // search disabled } func NewSnowFlake() *sonyflake.Sonyflake { @@ -44,6 +60,11 @@ func NewSnowFlake() *sonyflake.Sonyflake { }) } +func (d defaultSearcherRepo) NewID(ctx context.Context) (int64, error) { + id, err := d.sf.NextID() + return int64(id), err +} + func (r *bleveSearcherRepo) NewID(ctx context.Context) (int64, error) { id, err := r.sf.NextID() return int64(id), err diff --git a/app/sephirah/cmd/sephirah/wire.go b/app/sephirah/cmd/sephirah/wire.go index 035743f9..e0418b2e 100644 --- a/app/sephirah/cmd/sephirah/wire.go +++ b/app/sephirah/cmd/sephirah/wire.go @@ -25,9 +25,9 @@ import ( // wireApp init kratos application. func wireApp( - *conf.Sephirah_Server, - *conf.Sephirah_Data, - *conf.Sephirah_Porter, + *conf.SephirahServer, + *conf.SephirahData, + *conf.Porter, *conf.Auth, *conf.MQ, *conf.Cache, diff --git a/app/sephirah/cmd/sephirah/wire_gen.go b/app/sephirah/cmd/sephirah/wire_gen.go index e5fe1521..bf0349b3 100644 --- a/app/sephirah/cmd/sephirah/wire_gen.go +++ b/app/sephirah/cmd/sephirah/wire_gen.go @@ -32,7 +32,7 @@ import ( // Injectors from wire.go: // wireApp init kratos application. -func wireApp(sephirah_Server *conf.Sephirah_Server, sephirah_Data *conf.Sephirah_Data, sephirah_Porter *conf.Sephirah_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, 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) { libauthAuth, err := libauth.NewAuth(auth) if err != nil { return nil, nil, err @@ -41,7 +41,7 @@ func wireApp(sephirah_Server *conf.Sephirah_Server, sephirah_Data *conf.Sephirah if err != nil { return nil, nil, err } - entClient, cleanup2, err := data.NewSQLClient(sephirah_Data) + entClient, cleanup2, err := data.NewSQLClient(sephirahData, settings) if err != nil { cleanup() return nil, nil, err @@ -54,13 +54,13 @@ func wireApp(sephirah_Server *conf.Sephirah_Server, sephirah_Data *conf.Sephirah cleanup() return nil, nil, err } - porter, err := client.NewPorter(librarianPorterServiceClient, consul) + clientPorter, err := client.NewPorter(librarianPorterServiceClient, consul) if err != nil { cleanup2() cleanup() return nil, nil, err } - supervisorSupervisor, err := supervisor.NewSupervisor(sephirah_Porter, libauthAuth, porter) + supervisorSupervisor, err := supervisor.NewSupervisor(porter, libauthAuth, clientPorter) if err != nil { cleanup2() cleanup() @@ -114,7 +114,7 @@ func wireApp(sephirah_Server *conf.Sephirah_Server, sephirah_Data *conf.Sephirah return nil, nil, err } gebura := bizgebura.NewGebura(geburaRepo, libauthAuth, searcher, topic, libmqTopic, libcacheMap) - binahRepo, err := data.NewBinahRepo(sephirah_Data) + binahRepo, err := data.NewBinahRepo(sephirahData) if err != nil { cleanup2() cleanup() @@ -146,13 +146,13 @@ func wireApp(sephirah_Server *conf.Sephirah_Server, sephirah_Data *conf.Sephirah } v := server.NewAuthMiddleware(libauthAuth) librarianSephirahServiceServer := service.NewLibrarianSephirahServiceService(angela, tiphereth, gebura, binah, yesod, netzach, chesed, supervisorSupervisor, settings, libauthAuth, v) - grpcServer, err := server.NewGRPCServer(sephirah_Server, libauthAuth, librarianSephirahServiceServer, settings) + grpcServer, err := server.NewGRPCServer(sephirahServer, libauthAuth, librarianSephirahServiceServer, settings) if err != nil { cleanup2() cleanup() return nil, nil, err } - httpServer, err := server.NewGrpcWebServer(grpcServer, sephirah_Server, libauthAuth, settings) + httpServer, err := server.NewGrpcWebServer(grpcServer, sephirahServer, libauthAuth, settings) if err != nil { cleanup2() cleanup() diff --git a/app/sephirah/internal/data/binah.go b/app/sephirah/internal/data/binah.go index a7f19e95..7ea8f38c 100644 --- a/app/sephirah/internal/data/binah.go +++ b/app/sephirah/internal/data/binah.go @@ -19,7 +19,7 @@ type binahRepo struct { buckets map[bizbinah.Bucket]string } -func NewBinahRepo(c *conf.Sephirah_Data) (bizbinah.BinahRepo, error) { +func NewBinahRepo(c *conf.SephirahData) (bizbinah.BinahRepo, error) { if c == nil || c.GetS3() == nil { return new(binahRepo), nil } diff --git a/app/sephirah/internal/data/data.go b/app/sephirah/internal/data/data.go index 469ad903..dd80bfba 100644 --- a/app/sephirah/internal/data/data.go +++ b/app/sephirah/internal/data/data.go @@ -4,10 +4,12 @@ import ( "context" "errors" "fmt" + "path" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent" "github.com/tuihub/librarian/app/sephirah/internal/data/internal/ent/migrate" "github.com/tuihub/librarian/internal/conf" + "github.com/tuihub/librarian/internal/lib/libapp" "github.com/tuihub/librarian/internal/lib/logger" "entgo.io/ent/dialect/sql" @@ -31,6 +33,12 @@ var ProviderSet = wire.NewSet( NewBinahRepo, ) +const ( + driverMemory = "memory" + driverSQLite3 = "sqlite3" + driverPostgres = "postgres" +) + // Data . type Data struct { db *ent.Client @@ -43,13 +51,22 @@ func NewData(db *ent.Client) *Data { } } -func NewSQLClient(c *conf.Sephirah_Data) (*ent.Client, func(), error) { +func NewSQLClient(c *conf.SephirahData, app *libapp.Settings) (*ent.Client, func(), error) { var driverName, dataSourceName string + if c == nil { + c = new(conf.SephirahData) + } driverName = c.GetDatabase().GetDriver() + if driverName == "" { + logger.Warnf("database driver is empty, using memory mode.") + driverName = driverMemory + } switch driverName { - case "sqlite3": + case driverMemory: dataSourceName = "file:ent?mode=memory&cache=shared&_fk=1" - case "postgres": + case driverSQLite3: + 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(), @@ -63,9 +80,12 @@ func NewSQLClient(c *conf.Sephirah_Data) (*ent.Client, func(), error) { default: return nil, func() {}, errors.New("unsupported sql database") } + if driverName == driverMemory { + driverName = driverSQLite3 + } client, err := ent.Open(driverName, dataSourceName) if err != nil { - logger.Errorf("failed opening connection to postgres: %v", err) + logger.Errorf("failed opening connection to database: %v", err) return nil, func() {}, err } // Run the auto migration tool. diff --git a/app/sephirah/internal/supervisor/supervisor.go b/app/sephirah/internal/supervisor/supervisor.go index 794c2276..9abf9521 100644 --- a/app/sephirah/internal/supervisor/supervisor.go +++ b/app/sephirah/internal/supervisor/supervisor.go @@ -32,12 +32,12 @@ type Supervisor struct { } func NewSupervisor( - c *conf.Sephirah_Porter, + c *conf.Porter, auth *libauth.Auth, porter *client.Porter, ) (*Supervisor, error) { if c == nil { - c = new(conf.Sephirah_Porter) + c = new(conf.Porter) } return &Supervisor{ porter: porter, diff --git a/app/sephirah/pkg/service/wire.go b/app/sephirah/pkg/service/wire.go index 5b59d17d..66ecef1f 100644 --- a/app/sephirah/pkg/service/wire.go +++ b/app/sephirah/pkg/service/wire.go @@ -26,8 +26,8 @@ import ( ) func NewSephirahService( - *conf.Sephirah_Data, - *conf.Sephirah_Porter, + *conf.SephirahData, + *conf.Porter, *conf.Consul, *libauth.Auth, *libmq.MQ, diff --git a/app/sephirah/pkg/service/wire_gen.go b/app/sephirah/pkg/service/wire_gen.go index 5093984f..4629c291 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(sephirah_Data *conf.Sephirah_Data, sephirah_Porter *conf.Sephirah_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(sephirah_Data) +func NewSephirahService(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) if err != nil { return nil, nil, err } @@ -44,12 +44,12 @@ func NewSephirahService(sephirah_Data *conf.Sephirah_Data, sephirah_Porter *conf cleanup() return nil, nil, err } - porter, err := client.NewPorter(librarianPorterServiceClient, consul) + clientPorter, err := client.NewPorter(librarianPorterServiceClient, consul) if err != nil { cleanup() return nil, nil, err } - supervisorSupervisor, err := supervisor.NewSupervisor(sephirah_Porter, auth, porter) + supervisorSupervisor, err := supervisor.NewSupervisor(porter, auth, clientPorter) if err != nil { cleanup() return nil, nil, err @@ -86,7 +86,7 @@ func NewSephirahService(sephirah_Data *conf.Sephirah_Data, sephirah_Porter *conf return nil, nil, err } gebura := bizgebura.NewGebura(geburaRepo, auth, searcher, topic, libmqTopic, libcacheMap) - binahRepo, err := data.NewBinahRepo(sephirah_Data) + binahRepo, err := data.NewBinahRepo(sephirahData) if err != nil { cleanup() return nil, nil, err diff --git a/cmd/librarian/main.go b/cmd/librarian/main.go index 097ebe31..4fa33798 100644 --- a/cmd/librarian/main.go +++ b/cmd/librarian/main.go @@ -68,16 +68,16 @@ func main() { app, cleanup, err := wireApp( bc.GetEnableServiceDiscovery(), - bc.GetSephirah().GetServer(), - bc.GetSephirah().GetData(), - bc.GetSephirah().GetPorter(), + bc.GetServer(), + bc.GetData(), + bc.GetPorter(), bc.GetMapper().GetData(), bc.GetSearcher().GetData(), bc.GetMiner().GetData(), - bc.GetSephirah().GetAuth(), - bc.GetSephirah().GetMq(), - bc.GetSephirah().GetCache(), - bc.GetSephirah().GetConsul(), + bc.GetAuth(), + bc.GetMq(), + bc.GetCache(), + bc.GetConsul(), appSettings, ) if err != nil { diff --git a/cmd/librarian/wire.go b/cmd/librarian/wire.go index ca9a8980..e58ebcc1 100644 --- a/cmd/librarian/wire.go +++ b/cmd/librarian/wire.go @@ -24,9 +24,9 @@ import ( // wireApp init kratos application. func wireApp( *conf.Librarian_EnableServiceDiscovery, - *conf.Sephirah_Server, - *conf.Sephirah_Data, - *conf.Sephirah_Porter, + *conf.SephirahServer, + *conf.SephirahData, + *conf.Porter, *conf.Mapper_Data, *conf.Searcher_Data, *conf.Miner_Data, diff --git a/cmd/librarian/wire_gen.go b/cmd/librarian/wire_gen.go index 158faa60..ff7f09a0 100644 --- a/cmd/librarian/wire_gen.go +++ b/cmd/librarian/wire_gen.go @@ -24,7 +24,7 @@ import ( // Injectors from wire.go: // wireApp init kratos application. -func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDiscovery, sephirah_Server *conf.Sephirah_Server, sephirah_Data *conf.Sephirah_Data, sephirah_Porter *conf.Sephirah_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, 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) { libauthAuth, err := libauth.NewAuth(auth) if err != nil { return nil, nil, err @@ -65,14 +65,14 @@ func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDisco cleanup() return nil, nil, err } - librarianSephirahServiceServer, cleanup4, err := service3.NewSephirahService(sephirah_Data, sephirah_Porter, consul, libauthAuth, libmqMQ, cron, store, settings, librarianSearcherServiceClient, librarianMinerServiceClient) + librarianSephirahServiceServer, cleanup4, err := service3.NewSephirahService(sephirahData, porter, consul, libauthAuth, libmqMQ, cron, store, settings, librarianSearcherServiceClient, librarianMinerServiceClient) if err != nil { cleanup3() cleanup2() cleanup() return nil, nil, err } - grpcServer, err := server.NewGRPCServer(sephirah_Server, libauthAuth, librarianSephirahServiceServer, settings) + grpcServer, err := server.NewGRPCServer(sephirahServer, libauthAuth, librarianSephirahServiceServer, settings) if err != nil { cleanup4() cleanup3() @@ -80,7 +80,7 @@ func wireApp(librarian_EnableServiceDiscovery *conf.Librarian_EnableServiceDisco cleanup() return nil, nil, err } - httpServer, err := server.NewGrpcWebServer(grpcServer, sephirah_Server, libauthAuth, settings) + httpServer, err := server.NewGrpcWebServer(grpcServer, sephirahServer, libauthAuth, settings) if err != nil { cleanup4() cleanup3() diff --git a/configs/example-for-single-node.yaml b/configs/example-for-single-node.yaml index e4352f0d..343d6fbc 100644 --- a/configs/example-for-single-node.yaml +++ b/configs/example-for-single-node.yaml @@ -1,41 +1,40 @@ -sephirah: - server: - grpc: - addr: 0.0.0.0:10000 - timeout: 1s - 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 - auth: - salt: test - issuer: test - jwt_secret: test - mq: - driver: sql - database: - driver: postgres - host: localhost - port: 5432 - dbname: librarian - user: librarian - password: librarian - no_ssl: true - cache: - driver: memory +server: + grpc: + addr: 0.0.0.0:10000 + timeout: 1s + 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 +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 +cache: + driver: memory searcher: data: meilisearch: diff --git a/configs/example-for-testing.yaml b/configs/example-for-testing.yaml index 4114d86c..8c1934ce 100644 --- a/configs/example-for-testing.yaml +++ b/configs/example-for-testing.yaml @@ -1,23 +1,22 @@ -sephirah: - server: - grpc: - addr: 0.0.0.0:10000 - timeout: 1s - grpc_web: - addr: 0.0.0.0:10001 - timeout: 1s - data: - database: - driver: sqlite3 - s3: - auth: - salt: test - issuer: test - jwt_secret: test - mq: - driver: memory - cache: +server: + grpc: + addr: 0.0.0.0:10000 + timeout: 60s + grpc_web: + addr: 0.0.0.0:10001 + timeout: 60s +data: + database: driver: memory + s3: +auth: + password_salt: test + jwt_issuer: test + jwt_secret: test +mq: + driver: memory +cache: + driver: memory searcher: data: bleve: diff --git a/internal/conf/base.pb.go b/internal/conf/base.pb.go index 44c8a109..05fd1c79 100644 --- a/internal/conf/base.pb.go +++ b/internal/conf/base.pb.go @@ -239,9 +239,9 @@ type Auth struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Salt string `protobuf:"bytes,1,opt,name=salt,proto3" json:"salt,omitempty"` - Issuer string `protobuf:"bytes,2,opt,name=issuer,proto3" json:"issuer,omitempty"` - JwtSecret string `protobuf:"bytes,3,opt,name=jwt_secret,json=jwtSecret,proto3" json:"jwt_secret,omitempty"` + PasswordSalt string `protobuf:"bytes,1,opt,name=password_salt,json=passwordSalt,proto3" json:"password_salt,omitempty"` + JwtIssuer string `protobuf:"bytes,2,opt,name=jwt_issuer,json=jwtIssuer,proto3" json:"jwt_issuer,omitempty"` + JwtSecret string `protobuf:"bytes,3,opt,name=jwt_secret,json=jwtSecret,proto3" json:"jwt_secret,omitempty"` } func (x *Auth) Reset() { @@ -276,16 +276,16 @@ func (*Auth) Descriptor() ([]byte, []int) { return file_conf_base_proto_rawDescGZIP(), []int{3} } -func (x *Auth) GetSalt() string { +func (x *Auth) GetPasswordSalt() string { if x != nil { - return x.Salt + return x.PasswordSalt } return "" } -func (x *Auth) GetIssuer() string { +func (x *Auth) GetJwtIssuer() string { if x != nil { - return x.Issuer + return x.JwtIssuer } return "" } @@ -428,20 +428,21 @@ var file_conf_base_proto_rawDesc = []byte{ 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, 0x51, 0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, - 0x73, 0x61, 0x6c, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x61, 0x6c, 0x74, - 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x73, 0x75, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x69, 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, 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, + 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, 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 ( diff --git a/internal/conf/base.proto b/internal/conf/base.proto index d58ed117..b5b80208 100644 --- a/internal/conf/base.proto +++ b/internal/conf/base.proto @@ -27,8 +27,8 @@ message MQ { } message Auth { - string salt = 1; - string issuer = 2; + string password_salt = 1; + string jwt_issuer = 2; string jwt_secret = 3; } diff --git a/internal/conf/librarian.pb.go b/internal/conf/librarian.pb.go index 0e211fee..eee07ddc 100644 --- a/internal/conf/librarian.pb.go +++ b/internal/conf/librarian.pb.go @@ -25,11 +25,17 @@ type Librarian struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - EnableServiceDiscovery *Librarian_EnableServiceDiscovery `protobuf:"bytes,1,opt,name=enable_service_discovery,json=enableServiceDiscovery,proto3" json:"enable_service_discovery,omitempty"` - Sephirah *Sephirah `protobuf:"bytes,2,opt,name=sephirah,proto3" json:"sephirah,omitempty"` - Mapper *Mapper `protobuf:"bytes,3,opt,name=mapper,proto3" json:"mapper,omitempty"` - Searcher *Searcher `protobuf:"bytes,4,opt,name=searcher,proto3" json:"searcher,omitempty"` - Miner *Miner `protobuf:"bytes,5,opt,name=miner,proto3" json:"miner,omitempty"` + 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"` + 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"` } func (x *Librarian) Reset() { @@ -71,9 +77,51 @@ func (x *Librarian) GetEnableServiceDiscovery() *Librarian_EnableServiceDiscover return nil } -func (x *Librarian) GetSephirah() *Sephirah { +func (x *Librarian) GetServer() *SephirahServer { if x != nil { - return x.Sephirah + return x.Server + } + return nil +} + +func (x *Librarian) GetData() *SephirahData { + if x != nil { + return x.Data + } + return nil +} + +func (x *Librarian) GetAuth() *Auth { + if x != nil { + return x.Auth + } + return nil +} + +func (x *Librarian) GetMq() *MQ { + if x != nil { + return x.Mq + } + return nil +} + +func (x *Librarian) GetCache() *Cache { + if x != nil { + return x.Cache + } + return nil +} + +func (x *Librarian) GetPorter() *Porter { + if x != nil { + return x.Porter + } + return nil +} + +func (x *Librarian) GetConsul() *Consul { + if x != nil { + return x.Consul } return nil } @@ -175,41 +223,57 @@ var File_conf_librarian_proto protoreflect.FileDescriptor var file_conf_librarian_proto_rawDesc = []byte{ 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, - 0x70, 0x69, 0x1a, 0x13, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x73, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, - 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x11, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x6d, 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, 0xa8, 0x03, 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, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2c, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c, - 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, - 0x16, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x69, - 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x12, 0x30, 0x0a, 0x08, 0x73, 0x65, 0x70, 0x68, 0x69, - 0x72, 0x61, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x6b, 0x72, 0x61, 0x74, - 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x52, - 0x08, 0x73, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x12, 0x2a, 0x0a, 0x06, 0x6d, 0x61, 0x70, - 0x70, 0x65, 0x72, 0x18, 0x03, 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, 0x04, 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, 0x05, 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, + 0x70, 0x69, 0x1a, 0x0f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x13, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x73, 0x65, 0x70, 0x68, 0x69, 0x72, + 0x61, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x11, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x6d, + 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, 0x9f, 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, + 0x4c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, + 0x52, 0x16, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, + 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, 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 ( @@ -228,22 +292,34 @@ var file_conf_librarian_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_conf_librarian_proto_goTypes = []interface{}{ (*Librarian)(nil), // 0: kratos.api.Librarian (*Librarian_EnableServiceDiscovery)(nil), // 1: kratos.api.Librarian.EnableServiceDiscovery - (*Sephirah)(nil), // 2: kratos.api.Sephirah - (*Mapper)(nil), // 3: kratos.api.Mapper - (*Searcher)(nil), // 4: kratos.api.Searcher - (*Miner)(nil), // 5: kratos.api.Miner + (*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 + (*Mapper)(nil), // 9: kratos.api.Mapper + (*Searcher)(nil), // 10: kratos.api.Searcher + (*Miner)(nil), // 11: 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.sephirah:type_name -> kratos.api.Sephirah - 3, // 2: kratos.api.Librarian.mapper:type_name -> kratos.api.Mapper - 4, // 3: kratos.api.Librarian.searcher:type_name -> kratos.api.Searcher - 5, // 4: kratos.api.Librarian.miner:type_name -> kratos.api.Miner - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 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.mapper:type_name -> kratos.api.Mapper + 10, // 9: kratos.api.Librarian.searcher:type_name -> kratos.api.Searcher + 11, // 10: kratos.api.Librarian.miner:type_name -> kratos.api.Miner + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_conf_librarian_proto_init() } @@ -251,6 +327,7 @@ func file_conf_librarian_proto_init() { if File_conf_librarian_proto != nil { return } + file_conf_base_proto_init() file_conf_sephirah_proto_init() file_conf_mapper_proto_init() file_conf_searcher_proto_init() diff --git a/internal/conf/librarian.proto b/internal/conf/librarian.proto index 8b426ed0..1e3bb797 100644 --- a/internal/conf/librarian.proto +++ b/internal/conf/librarian.proto @@ -3,6 +3,7 @@ package kratos.api; option go_package = "Librarian/internal/conf;conf"; +import "conf/base.proto"; import "conf/sephirah.proto"; import "conf/mapper.proto"; import "conf/searcher.proto"; @@ -15,10 +16,18 @@ message Librarian { bool porter = 3; bool miner = 4; } - EnableServiceDiscovery enable_service_discovery = 1; - Sephirah sephirah = 2; - Mapper mapper = 3; - Searcher searcher = 4; - Miner miner = 5; + 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; + + Mapper mapper = 11; + Searcher searcher = 12; + Miner miner = 13; } diff --git a/internal/conf/sephirah.pb.go b/internal/conf/sephirah.pb.go index 100ae1b7..d767c36b 100644 --- a/internal/conf/sephirah.pb.go +++ b/internal/conf/sephirah.pb.go @@ -20,22 +20,17 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type Sephirah struct { +type SephirahServer struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Server *Sephirah_Server `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"` - Data *Sephirah_Data `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 *Sephirah_Porter `protobuf:"bytes,6,opt,name=porter,proto3" json:"porter,omitempty"` - Consul *Consul `protobuf:"bytes,7,opt,name=consul,proto3" json:"consul,omitempty"` + Grpc *GRPC `protobuf:"bytes,1,opt,name=grpc,proto3" json:"grpc,omitempty"` + GrpcWeb *GRPC `protobuf:"bytes,2,opt,name=grpc_web,json=grpcWeb,proto3" json:"grpc_web,omitempty"` } -func (x *Sephirah) Reset() { - *x = Sephirah{} +func (x *SephirahServer) Reset() { + *x = SephirahServer{} if protoimpl.UnsafeEnabled { mi := &file_conf_sephirah_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -43,13 +38,13 @@ func (x *Sephirah) Reset() { } } -func (x *Sephirah) String() string { +func (x *SephirahServer) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Sephirah) ProtoMessage() {} +func (*SephirahServer) ProtoMessage() {} -func (x *Sephirah) ProtoReflect() protoreflect.Message { +func (x *SephirahServer) ProtoReflect() protoreflect.Message { mi := &file_conf_sephirah_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -61,71 +56,36 @@ func (x *Sephirah) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Sephirah.ProtoReflect.Descriptor instead. -func (*Sephirah) Descriptor() ([]byte, []int) { +// Deprecated: Use SephirahServer.ProtoReflect.Descriptor instead. +func (*SephirahServer) Descriptor() ([]byte, []int) { return file_conf_sephirah_proto_rawDescGZIP(), []int{0} } -func (x *Sephirah) GetServer() *Sephirah_Server { - if x != nil { - return x.Server - } - return nil -} - -func (x *Sephirah) GetData() *Sephirah_Data { - if x != nil { - return x.Data - } - return nil -} - -func (x *Sephirah) GetAuth() *Auth { - if x != nil { - return x.Auth - } - return nil -} - -func (x *Sephirah) GetMq() *MQ { - if x != nil { - return x.Mq - } - return nil -} - -func (x *Sephirah) GetCache() *Cache { +func (x *SephirahServer) GetGrpc() *GRPC { if x != nil { - return x.Cache - } - return nil -} - -func (x *Sephirah) GetPorter() *Sephirah_Porter { - if x != nil { - return x.Porter + return x.Grpc } return nil } -func (x *Sephirah) GetConsul() *Consul { +func (x *SephirahServer) GetGrpcWeb() *GRPC { if x != nil { - return x.Consul + return x.GrpcWeb } return nil } -type Sephirah_Server struct { +type SephirahData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Grpc *GRPC `protobuf:"bytes,1,opt,name=grpc,proto3" json:"grpc,omitempty"` - GrpcWeb *GRPC `protobuf:"bytes,2,opt,name=grpc_web,json=grpcWeb,proto3" json:"grpc_web,omitempty"` + 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 *Sephirah_Server) Reset() { - *x = Sephirah_Server{} +func (x *SephirahData) Reset() { + *x = SephirahData{} if protoimpl.UnsafeEnabled { mi := &file_conf_sephirah_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -133,13 +93,13 @@ func (x *Sephirah_Server) Reset() { } } -func (x *Sephirah_Server) String() string { +func (x *SephirahData) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Sephirah_Server) ProtoMessage() {} +func (*SephirahData) ProtoMessage() {} -func (x *Sephirah_Server) ProtoReflect() protoreflect.Message { +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)) @@ -151,36 +111,35 @@ func (x *Sephirah_Server) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Sephirah_Server.ProtoReflect.Descriptor instead. -func (*Sephirah_Server) Descriptor() ([]byte, []int) { - return file_conf_sephirah_proto_rawDescGZIP(), []int{0, 0} +// Deprecated: Use SephirahData.ProtoReflect.Descriptor instead. +func (*SephirahData) Descriptor() ([]byte, []int) { + return file_conf_sephirah_proto_rawDescGZIP(), []int{1} } -func (x *Sephirah_Server) GetGrpc() *GRPC { +func (x *SephirahData) GetDatabase() *Database { if x != nil { - return x.Grpc + return x.Database } return nil } -func (x *Sephirah_Server) GetGrpcWeb() *GRPC { +func (x *SephirahData) GetS3() *SephirahData_S3 { if x != nil { - return x.GrpcWeb + return x.S3 } return nil } -type Sephirah_Data struct { +type Porter struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Database *Database `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"` - S3 *Sephirah_Data_S3 `protobuf:"bytes,2,opt,name=s3,proto3" json:"s3,omitempty"` + TrustedAddress []string `protobuf:"bytes,1,rep,name=trusted_address,json=trustedAddress,proto3" json:"trusted_address,omitempty"` } -func (x *Sephirah_Data) Reset() { - *x = Sephirah_Data{} +func (x *Porter) Reset() { + *x = Porter{} if protoimpl.UnsafeEnabled { mi := &file_conf_sephirah_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -188,13 +147,13 @@ func (x *Sephirah_Data) Reset() { } } -func (x *Sephirah_Data) String() string { +func (x *Porter) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Sephirah_Data) ProtoMessage() {} +func (*Porter) ProtoMessage() {} -func (x *Sephirah_Data) ProtoReflect() protoreflect.Message { +func (x *Porter) ProtoReflect() protoreflect.Message { mi := &file_conf_sephirah_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -206,35 +165,34 @@ func (x *Sephirah_Data) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Sephirah_Data.ProtoReflect.Descriptor instead. -func (*Sephirah_Data) Descriptor() ([]byte, []int) { - return file_conf_sephirah_proto_rawDescGZIP(), []int{0, 1} -} - -func (x *Sephirah_Data) GetDatabase() *Database { - if x != nil { - return x.Database - } - return nil +// Deprecated: Use Porter.ProtoReflect.Descriptor instead. +func (*Porter) Descriptor() ([]byte, []int) { + return file_conf_sephirah_proto_rawDescGZIP(), []int{2} } -func (x *Sephirah_Data) GetS3() *Sephirah_Data_S3 { +func (x *Porter) GetTrustedAddress() []string { if x != nil { - return x.S3 + return x.TrustedAddress } return nil } -type Sephirah_Porter struct { +type Sephirah struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - TrustedAddress []string `protobuf:"bytes,1,rep,name=trusted_address,json=trustedAddress,proto3" json:"trusted_address,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"` } -func (x *Sephirah_Porter) Reset() { - *x = Sephirah_Porter{} +func (x *Sephirah) Reset() { + *x = Sephirah{} if protoimpl.UnsafeEnabled { mi := &file_conf_sephirah_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -242,13 +200,13 @@ func (x *Sephirah_Porter) Reset() { } } -func (x *Sephirah_Porter) String() string { +func (x *Sephirah) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Sephirah_Porter) ProtoMessage() {} +func (*Sephirah) ProtoMessage() {} -func (x *Sephirah_Porter) ProtoReflect() protoreflect.Message { +func (x *Sephirah) ProtoReflect() protoreflect.Message { mi := &file_conf_sephirah_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -260,19 +218,61 @@ func (x *Sephirah_Porter) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Sephirah_Porter.ProtoReflect.Descriptor instead. -func (*Sephirah_Porter) Descriptor() ([]byte, []int) { - return file_conf_sephirah_proto_rawDescGZIP(), []int{0, 2} +// Deprecated: Use Sephirah.ProtoReflect.Descriptor instead. +func (*Sephirah) Descriptor() ([]byte, []int) { + return file_conf_sephirah_proto_rawDescGZIP(), []int{3} } -func (x *Sephirah_Porter) GetTrustedAddress() []string { +func (x *Sephirah) GetServer() *SephirahServer { if x != nil { - return x.TrustedAddress + return x.Server + } + return nil +} + +func (x *Sephirah) GetData() *SephirahData { + if x != nil { + return x.Data + } + return nil +} + +func (x *Sephirah) GetAuth() *Auth { + if x != nil { + return x.Auth } return nil } -type Sephirah_Data_S3 struct { +func (x *Sephirah) GetMq() *MQ { + if x != nil { + return x.Mq + } + return nil +} + +func (x *Sephirah) GetCache() *Cache { + if x != nil { + return x.Cache + } + return nil +} + +func (x *Sephirah) GetPorter() *Porter { + if x != nil { + return x.Porter + } + return nil +} + +func (x *Sephirah) GetConsul() *Consul { + if x != nil { + return x.Consul + } + return nil +} + +type SephirahData_S3 struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -283,8 +283,8 @@ type Sephirah_Data_S3 struct { UseSsl bool `protobuf:"varint,4,opt,name=use_ssl,json=useSsl,proto3" json:"use_ssl,omitempty"` } -func (x *Sephirah_Data_S3) Reset() { - *x = Sephirah_Data_S3{} +func (x *SephirahData_S3) Reset() { + *x = SephirahData_S3{} if protoimpl.UnsafeEnabled { mi := &file_conf_sephirah_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -292,13 +292,13 @@ func (x *Sephirah_Data_S3) Reset() { } } -func (x *Sephirah_Data_S3) String() string { +func (x *SephirahData_S3) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Sephirah_Data_S3) ProtoMessage() {} +func (*SephirahData_S3) ProtoMessage() {} -func (x *Sephirah_Data_S3) ProtoReflect() protoreflect.Message { +func (x *SephirahData_S3) ProtoReflect() protoreflect.Message { mi := &file_conf_sephirah_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -310,33 +310,33 @@ func (x *Sephirah_Data_S3) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Sephirah_Data_S3.ProtoReflect.Descriptor instead. -func (*Sephirah_Data_S3) Descriptor() ([]byte, []int) { - return file_conf_sephirah_proto_rawDescGZIP(), []int{0, 1, 0} +// Deprecated: Use SephirahData_S3.ProtoReflect.Descriptor instead. +func (*SephirahData_S3) Descriptor() ([]byte, []int) { + return file_conf_sephirah_proto_rawDescGZIP(), []int{1, 0} } -func (x *Sephirah_Data_S3) GetEndPoint() string { +func (x *SephirahData_S3) GetEndPoint() string { if x != nil { return x.EndPoint } return "" } -func (x *Sephirah_Data_S3) GetAccessKey() string { +func (x *SephirahData_S3) GetAccessKey() string { if x != nil { return x.AccessKey } return "" } -func (x *Sephirah_Data_S3) GetSecretKey() string { +func (x *SephirahData_S3) GetSecretKey() string { if x != nil { return x.SecretKey } return "" } -func (x *Sephirah_Data_S3) GetUseSsl() bool { +func (x *SephirahData_S3) GetUseSsl() bool { if x != nil { return x.UseSsl } @@ -349,13 +349,37 @@ var file_conf_sephirah_proto_rawDesc = []byte{ 0x0a, 0x13, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x73, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x0f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0xb1, 0x05, 0x0a, 0x08, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x12, - 0x33, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 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, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x12, 0x2d, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, - 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, + 0x74, 0x6f, 0x22, 0x63, 0x0a, 0x0e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x53, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x12, 0x24, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x47, 0x52, 0x50, 0x43, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x12, 0x2b, 0x0a, 0x08, 0x67, 0x72, + 0x70, 0x63, 0x5f, 0x77, 0x65, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, + 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, 0x07, + 0x67, 0x72, 0x70, 0x63, 0x57, 0x65, 0x62, 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, 0xb3, 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, @@ -363,38 +387,15 @@ var file_conf_sephirah_proto_rawDesc = []byte{ 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, 0x33, 0x0a, 0x06, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x72, 0x18, 0x06, 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, 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, 0x1a, 0x5b, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x24, 0x0a, - 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, - 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, 0x04, 0x67, - 0x72, 0x70, 0x63, 0x12, 0x2b, 0x0a, 0x08, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x77, 0x65, 0x62, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x47, 0x52, 0x50, 0x43, 0x52, 0x07, 0x67, 0x72, 0x70, 0x63, 0x57, 0x65, 0x62, - 0x1a, 0xe0, 0x01, 0x0a, 0x04, 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, 0x2c, 0x0a, 0x02, 0x73, - 0x33, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, - 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x53, 0x65, 0x70, 0x68, 0x69, 0x72, 0x61, 0x68, 0x2e, 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, 0x1a, 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, 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, + 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, 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 ( @@ -411,30 +412,30 @@ func file_conf_sephirah_proto_rawDescGZIP() []byte { var file_conf_sephirah_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_conf_sephirah_proto_goTypes = []interface{}{ - (*Sephirah)(nil), // 0: kratos.api.Sephirah - (*Sephirah_Server)(nil), // 1: kratos.api.Sephirah.Server - (*Sephirah_Data)(nil), // 2: kratos.api.Sephirah.Data - (*Sephirah_Porter)(nil), // 3: kratos.api.Sephirah.Porter - (*Sephirah_Data_S3)(nil), // 4: kratos.api.Sephirah.Data.S3 - (*Auth)(nil), // 5: kratos.api.Auth - (*MQ)(nil), // 6: kratos.api.MQ - (*Cache)(nil), // 7: kratos.api.Cache - (*Consul)(nil), // 8: kratos.api.Consul - (*GRPC)(nil), // 9: kratos.api.GRPC - (*Database)(nil), // 10: kratos.api.Database + (*SephirahServer)(nil), // 0: kratos.api.SephirahServer + (*SephirahData)(nil), // 1: kratos.api.SephirahData + (*Porter)(nil), // 2: kratos.api.Porter + (*Sephirah)(nil), // 3: kratos.api.Sephirah + (*SephirahData_S3)(nil), // 4: kratos.api.SephirahData.S3 + (*GRPC)(nil), // 5: kratos.api.GRPC + (*Database)(nil), // 6: kratos.api.Database + (*Auth)(nil), // 7: kratos.api.Auth + (*MQ)(nil), // 8: kratos.api.MQ + (*Cache)(nil), // 9: kratos.api.Cache + (*Consul)(nil), // 10: kratos.api.Consul } var file_conf_sephirah_proto_depIdxs = []int32{ - 1, // 0: kratos.api.Sephirah.server:type_name -> kratos.api.Sephirah.Server - 2, // 1: kratos.api.Sephirah.data:type_name -> kratos.api.Sephirah.Data - 5, // 2: kratos.api.Sephirah.auth:type_name -> kratos.api.Auth - 6, // 3: kratos.api.Sephirah.mq:type_name -> kratos.api.MQ - 7, // 4: kratos.api.Sephirah.cache:type_name -> kratos.api.Cache - 3, // 5: kratos.api.Sephirah.porter:type_name -> kratos.api.Sephirah.Porter - 8, // 6: kratos.api.Sephirah.consul:type_name -> kratos.api.Consul - 9, // 7: kratos.api.Sephirah.Server.grpc:type_name -> kratos.api.GRPC - 9, // 8: kratos.api.Sephirah.Server.grpc_web:type_name -> kratos.api.GRPC - 10, // 9: kratos.api.Sephirah.Data.database:type_name -> kratos.api.Database - 4, // 10: kratos.api.Sephirah.Data.s3:type_name -> kratos.api.Sephirah.Data.S3 + 5, // 0: kratos.api.SephirahServer.grpc:type_name -> kratos.api.GRPC + 5, // 1: kratos.api.SephirahServer.grpc_web:type_name -> kratos.api.GRPC + 6, // 2: kratos.api.SephirahData.database:type_name -> kratos.api.Database + 4, // 3: kratos.api.SephirahData.s3:type_name -> kratos.api.SephirahData.S3 + 0, // 4: kratos.api.Sephirah.server:type_name -> kratos.api.SephirahServer + 1, // 5: kratos.api.Sephirah.data:type_name -> kratos.api.SephirahData + 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 + 2, // 9: kratos.api.Sephirah.porter:type_name -> kratos.api.Porter + 10, // 10: kratos.api.Sephirah.consul:type_name -> kratos.api.Consul 11, // [11:11] is the sub-list for method output_type 11, // [11:11] is the sub-list for method input_type 11, // [11:11] is the sub-list for extension type_name @@ -450,7 +451,7 @@ func file_conf_sephirah_proto_init() { file_conf_base_proto_init() if !protoimpl.UnsafeEnabled { file_conf_sephirah_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Sephirah); i { + switch v := v.(*SephirahServer); i { case 0: return &v.state case 1: @@ -462,7 +463,7 @@ func file_conf_sephirah_proto_init() { } } file_conf_sephirah_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Sephirah_Server); i { + switch v := v.(*SephirahData); i { case 0: return &v.state case 1: @@ -474,7 +475,7 @@ func file_conf_sephirah_proto_init() { } } file_conf_sephirah_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Sephirah_Data); i { + switch v := v.(*Porter); i { case 0: return &v.state case 1: @@ -486,7 +487,7 @@ func file_conf_sephirah_proto_init() { } } file_conf_sephirah_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Sephirah_Porter); i { + switch v := v.(*Sephirah); i { case 0: return &v.state case 1: @@ -498,7 +499,7 @@ func file_conf_sephirah_proto_init() { } } file_conf_sephirah_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Sephirah_Data_S3); i { + switch v := v.(*SephirahData_S3); i { case 0: return &v.state case 1: diff --git a/internal/conf/sephirah.proto b/internal/conf/sephirah.proto index ddda71e7..cc06a46f 100644 --- a/internal/conf/sephirah.proto +++ b/internal/conf/sephirah.proto @@ -5,29 +5,29 @@ option go_package = "Librarian/internal/conf;conf"; import "conf/base.proto"; -message Sephirah { - message Server { - GRPC grpc = 1; - GRPC grpc_web = 2; - } +message SephirahServer { + GRPC grpc = 1; + GRPC grpc_web = 2; +} - message Data { - 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 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 Porter { + repeated string trusted_address = 1; +} - Server server = 1; - Data data = 2; +message Sephirah { + SephirahServer server = 1; + SephirahData data = 2; Auth auth = 3; MQ mq = 4; Cache cache = 5; diff --git a/internal/lib/libapp/app.go b/internal/lib/libapp/app.go index 1bd61732..bc3372fe 100644 --- a/internal/lib/libapp/app.go +++ b/internal/lib/libapp/app.go @@ -50,7 +50,7 @@ func NewAppSettings(id, name, version, protoVersion, date string) (*Settings, er if err := checkDataPath(flags.DataPath); err != nil { return nil, err } - initLogger(id, name, version, flags.DataPath, getInherentSettings().LogLevel) + initLogger(id, name, version, flags.DataPath, getInherentSettings().LogLevel, true) if e, err := loadEnv(); err != nil { return nil, err } else { @@ -81,11 +81,14 @@ func NewAppSettings(id, name, version, protoVersion, date string) (*Settings, er as.LogLevel = libzap.ErrorLevel } } - initLogger(id, name, version, as.DataPath, as.LogLevel) + initLogger(id, name, version, as.DataPath, as.LogLevel, as.ConfPath == "") return &as, nil } func (a *Settings) LoadConfig(conf interface{}) { + if a.ConfPath == "" { + return + } c := config.New( config.WithSource( file.NewSource(a.ConfPath), @@ -148,8 +151,14 @@ func loadEnv() (config.Config, error) { return c, nil } -func initLogger(id, name, version, dataPath string, logLevel libzap.Level) { - logger := log.With(zap.NewLogger(libzap.New(dataPath, logLevel)), +func initLogger(id, name, version, dataPath string, logLevel libzap.Level, useStdout bool) { + var l *zap.Logger + if useStdout { + l = zap.NewLogger(libzap.NewStdout(logLevel)) + } else { + l = zap.NewLogger(libzap.New(dataPath, logLevel)) + } + logger := log.With(l, "ts", log.DefaultTimestamp, "caller", log.DefaultCaller, "service.id", id, diff --git a/internal/lib/libapp/inherent_settings_release.go b/internal/lib/libapp/inherent_settings_release.go index 38a34de9..a12e7a4e 100644 --- a/internal/lib/libapp/inherent_settings_release.go +++ b/internal/lib/libapp/inherent_settings_release.go @@ -8,6 +8,6 @@ func getInherentSettings() InherentSettings { return InherentSettings{ EnablePanicRecovery: true, LogLevel: libzap.ErrorLevel, - DefaultConfPath: "./config.yaml", + DefaultConfPath: "", } } diff --git a/internal/lib/libauth/auth.go b/internal/lib/libauth/auth.go index 39e20078..d97240d7 100644 --- a/internal/lib/libauth/auth.go +++ b/internal/lib/libauth/auth.go @@ -1,8 +1,6 @@ package libauth import ( - "errors" - "github.com/tuihub/librarian/internal/conf" "github.com/google/wire" @@ -16,11 +14,11 @@ type Auth struct { func NewAuth(config *conf.Auth) (*Auth, error) { if config == nil { - return nil, errors.New("") + config = new(conf.Auth) } return &Auth{config: conf.Auth{ - Salt: config.GetSalt(), - Issuer: config.GetIssuer(), - JwtSecret: config.GetJwtSecret(), + PasswordSalt: config.GetPasswordSalt(), + JwtIssuer: config.GetJwtIssuer(), + JwtSecret: config.GetJwtSecret(), }}, nil } diff --git a/internal/lib/libauth/jwt.go b/internal/lib/libauth/jwt.go index 71927fe5..1264f67e 100644 --- a/internal/lib/libauth/jwt.go +++ b/internal/lib/libauth/jwt.go @@ -107,7 +107,7 @@ func (a *Auth) GenerateToken( UserType: userType, TransferMetadata: transferMetadata, RegisteredClaims: jwtv4.RegisteredClaims{ - Issuer: a.config.GetIssuer(), + Issuer: a.config.GetJwtIssuer(), Subject: "", Audience: nil, ExpiresAt: jwtv4.NewNumericDate(expireTime), diff --git a/internal/lib/libauth/password.go b/internal/lib/libauth/password.go index 1f5b2f08..353fc322 100644 --- a/internal/lib/libauth/password.go +++ b/internal/lib/libauth/password.go @@ -9,7 +9,7 @@ import ( func (a *Auth) GeneratePassword(password string) (string, error) { res, err := scrypt.Key( []byte(password), - []byte(a.config.GetSalt()), + []byte(a.config.GetPasswordSalt()), 1<<14, 8, 5, 32) //nolint:gomnd // based on https://tobtu.com/minimum-password-settings/ if err == nil { return hex.EncodeToString(res), nil diff --git a/internal/lib/libcache/cache.go b/internal/lib/libcache/cache.go index 82b6a841..db176b4b 100644 --- a/internal/lib/libcache/cache.go +++ b/internal/lib/libcache/cache.go @@ -4,6 +4,7 @@ import ( "errors" "github.com/tuihub/librarian/internal/conf" + "github.com/tuihub/librarian/internal/lib/logger" "github.com/dgraph-io/ristretto" "github.com/google/wire" @@ -12,10 +13,17 @@ import ( var ProviderSet = wire.NewSet(NewStore) -func NewStore(conf *conf.Cache) (Store, error) { +func NewStore(c *conf.Cache) (Store, error) { var res Store var err error - switch conf.GetDriver() { + if c == nil { + c = new(conf.Cache) + } + if c.GetDriver() == "" { + logger.Warnf("cache driver is not set, using memory as default") + c.Driver = "memory" + } + switch c.GetDriver() { case "memory": res, err = newRistrettoCache() case "redis": diff --git a/internal/lib/libmq/mq.go b/internal/lib/libmq/mq.go index 139a6088..20888615 100644 --- a/internal/lib/libmq/mq.go +++ b/internal/lib/libmq/mq.go @@ -32,6 +32,13 @@ type pubSub struct { func NewMQ(c *conf.MQ, app *libapp.Settings) (*MQ, func(), error) { loggerAdapter := newMQLogger() var ps *pubSub + if c == nil { + c = new(conf.MQ) + } + if c.GetDriver() == "" { + logger.Warnf("mq driver is not set, using memory as default") + c.Driver = "memory" + } switch c.GetDriver() { case "memory": ps = newGoChannelAdapter(loggerAdapter) diff --git a/internal/lib/libzap/zap.go b/internal/lib/libzap/zap.go index 62cace77..aacc6ed7 100644 --- a/internal/lib/libzap/zap.go +++ b/internal/lib/libzap/zap.go @@ -1,6 +1,7 @@ package libzap import ( + "os" "path" "go.uber.org/zap" @@ -68,6 +69,16 @@ func NewTeeWithRotate(teeOptions []TeeOption, zapOptions ...zap.Option) *zap.Log return zap.New(zapcore.NewTee(cores...), zapOptions...) } +func NewStdout(accessLogLevel Level) *zap.Logger { + encoderConfig := zap.NewProductionEncoderConfig() + core := zapcore.NewCore( + zapcore.NewConsoleEncoder(encoderConfig), + zapcore.Lock(os.Stdout), + accessLogLevel, + ) + return zap.New(core) +} + func New(basePath string, accessLogLevel Level) *zap.Logger { var tops = []TeeOption{ { diff --git a/internal/server/grpc.go b/internal/server/grpc.go index 7b57835b..e5aaeb04 100644 --- a/internal/server/grpc.go +++ b/internal/server/grpc.go @@ -15,7 +15,7 @@ import ( // NewGRPCServer new a gRPC server. func NewGRPCServer( - c *conf.Sephirah_Server, + c *conf.SephirahServer, auth *libauth.Auth, greeter pb.LibrarianSephirahServiceServer, app *libapp.Settings, diff --git a/internal/server/grpc_web.go b/internal/server/grpc_web.go index bae65622..872ac7b2 100644 --- a/internal/server/grpc_web.go +++ b/internal/server/grpc_web.go @@ -18,7 +18,7 @@ import ( func NewGrpcWebServer( s *grpc.Server, - c *conf.Sephirah_Server, + c *conf.SephirahServer, auth *libauth.Auth, app *libapp.Settings, ) (*http.Server, error) {