fix: align admin behavior and Kratos integrations

This commit is contained in:
2026-08-14 14:14:51 +08:00
parent 8c4c6ba661
commit e0b0e1d8c8
123 changed files with 4334 additions and 1877 deletions
+221 -48
View File
@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.11
// protoc-gen-go v1.36.12
// protoc v7.35.1
// source: conf/conf.proto
@@ -130,6 +130,7 @@ type Data struct {
state protoimpl.MessageState `protogen:"open.v1"`
Database *Data_Database `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"`
Redis *Data_Redis `protobuf:"bytes,2,opt,name=redis,proto3" json:"redis,omitempty"`
DatabaseList []*Data_Database `protobuf:"bytes,3,rep,name=database_list,json=databaseList,proto3" json:"database_list,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -178,6 +179,13 @@ func (x *Data) GetRedis() *Data_Redis {
return nil
}
func (x *Data) GetDatabaseList() []*Data_Database {
if x != nil {
return x.DatabaseList
}
return nil
}
// AdminBackend contains settings for the administration HTTP transport.
type AdminBackend struct {
state protoimpl.MessageState `protogen:"open.v1"`
@@ -188,8 +196,10 @@ type AdminBackend struct {
Email *AdminBackend_Email `protobuf:"bytes,5,opt,name=email,proto3" json:"email,omitempty"`
Storage *AdminBackend_Storage `protobuf:"bytes,6,opt,name=storage,proto3" json:"storage,omitempty"`
// ConfigPath is populated by the entrypoint and is not required in YAML.
ConfigPath string `protobuf:"bytes,7,opt,name=config_path,json=configPath,proto3" json:"config_path,omitempty"`
Media *AdminBackend_Media `protobuf:"bytes,8,opt,name=media,proto3" json:"media,omitempty"`
ConfigPath string `protobuf:"bytes,7,opt,name=config_path,json=configPath,proto3" json:"config_path,omitempty"`
Media *AdminBackend_Media `protobuf:"bytes,8,opt,name=media,proto3" json:"media,omitempty"`
DiskList []*AdminBackend_Disk `protobuf:"bytes,9,rep,name=disk_list,json=diskList,proto3" json:"disk_list,omitempty"`
System *AdminBackend_System `protobuf:"bytes,10,opt,name=system,proto3" json:"system,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -280,6 +290,20 @@ func (x *AdminBackend) GetMedia() *AdminBackend_Media {
return nil
}
func (x *AdminBackend) GetDiskList() []*AdminBackend_Disk {
if x != nil {
return x.DiskList
}
return nil
}
func (x *AdminBackend) GetSystem() *AdminBackend_System {
if x != nil {
return x.System
}
return nil
}
type Server_HTTP struct {
state protoimpl.MessageState `protogen:"open.v1"`
Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"`
@@ -351,6 +375,8 @@ type Data_Database struct {
Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"`
Config string `protobuf:"bytes,8,opt,name=config,proto3" json:"config,omitempty"`
Path string `protobuf:"bytes,9,opt,name=path,proto3" json:"path,omitempty"`
AliasName string `protobuf:"bytes,10,opt,name=alias_name,json=aliasName,proto3" json:"alias_name,omitempty"`
Disable bool `protobuf:"varint,11,opt,name=disable,proto3" json:"disable,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -448,6 +474,20 @@ func (x *Data_Database) GetPath() string {
return ""
}
func (x *Data_Database) GetAliasName() string {
if x != nil {
return x.AliasName
}
return ""
}
func (x *Data_Database) GetDisable() bool {
if x != nil {
return x.Disable
}
return false
}
type Data_Redis struct {
state protoimpl.MessageState `protogen:"open.v1"`
Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"`
@@ -848,6 +888,118 @@ func (x *AdminBackend_Media) GetSessionTtl() int32 {
return 0
}
type AdminBackend_Disk struct {
state protoimpl.MessageState `protogen:"open.v1"`
MountPoint string `protobuf:"bytes,1,opt,name=mount_point,json=mountPoint,proto3" json:"mount_point,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AdminBackend_Disk) Reset() {
*x = AdminBackend_Disk{}
mi := &file_conf_conf_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AdminBackend_Disk) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AdminBackend_Disk) ProtoMessage() {}
func (x *AdminBackend_Disk) ProtoReflect() protoreflect.Message {
mi := &file_conf_conf_proto_msgTypes[12]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AdminBackend_Disk.ProtoReflect.Descriptor instead.
func (*AdminBackend_Disk) Descriptor() ([]byte, []int) {
return file_conf_conf_proto_rawDescGZIP(), []int{3, 5}
}
func (x *AdminBackend_Disk) GetMountPoint() string {
if x != nil {
return x.MountPoint
}
return ""
}
type AdminBackend_System struct {
state protoimpl.MessageState `protogen:"open.v1"`
UseRedis bool `protobuf:"varint,1,opt,name=use_redis,json=useRedis,proto3" json:"use_redis,omitempty"`
UseMultipoint bool `protobuf:"varint,2,opt,name=use_multipoint,json=useMultipoint,proto3" json:"use_multipoint,omitempty"`
UseStrictAuth bool `protobuf:"varint,3,opt,name=use_strict_auth,json=useStrictAuth,proto3" json:"use_strict_auth,omitempty"`
DisableAutoMigrate bool `protobuf:"varint,4,opt,name=disable_auto_migrate,json=disableAutoMigrate,proto3" json:"disable_auto_migrate,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AdminBackend_System) Reset() {
*x = AdminBackend_System{}
mi := &file_conf_conf_proto_msgTypes[13]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AdminBackend_System) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AdminBackend_System) ProtoMessage() {}
func (x *AdminBackend_System) ProtoReflect() protoreflect.Message {
mi := &file_conf_conf_proto_msgTypes[13]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AdminBackend_System.ProtoReflect.Descriptor instead.
func (*AdminBackend_System) Descriptor() ([]byte, []int) {
return file_conf_conf_proto_rawDescGZIP(), []int{3, 6}
}
func (x *AdminBackend_System) GetUseRedis() bool {
if x != nil {
return x.UseRedis
}
return false
}
func (x *AdminBackend_System) GetUseMultipoint() bool {
if x != nil {
return x.UseMultipoint
}
return false
}
func (x *AdminBackend_System) GetUseStrictAuth() bool {
if x != nil {
return x.UseStrictAuth
}
return false
}
func (x *AdminBackend_System) GetDisableAutoMigrate() bool {
if x != nil {
return x.DisableAutoMigrate
}
return false
}
type AdminBackend_Storage struct {
state protoimpl.MessageState `protogen:"open.v1"`
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
@@ -864,7 +1016,7 @@ type AdminBackend_Storage struct {
func (x *AdminBackend_Storage) Reset() {
*x = AdminBackend_Storage{}
mi := &file_conf_conf_proto_msgTypes[12]
mi := &file_conf_conf_proto_msgTypes[14]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -876,7 +1028,7 @@ func (x *AdminBackend_Storage) String() string {
func (*AdminBackend_Storage) ProtoMessage() {}
func (x *AdminBackend_Storage) ProtoReflect() protoreflect.Message {
mi := &file_conf_conf_proto_msgTypes[12]
mi := &file_conf_conf_proto_msgTypes[14]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -889,7 +1041,7 @@ func (x *AdminBackend_Storage) ProtoReflect() protoreflect.Message {
// Deprecated: Use AdminBackend_Storage.ProtoReflect.Descriptor instead.
func (*AdminBackend_Storage) Descriptor() ([]byte, []int) {
return file_conf_conf_proto_rawDescGZIP(), []int{3, 5}
return file_conf_conf_proto_rawDescGZIP(), []int{3, 7}
}
func (x *AdminBackend_Storage) GetType() string {
@@ -963,7 +1115,7 @@ type AdminBackend_Qiniu struct {
func (x *AdminBackend_Qiniu) Reset() {
*x = AdminBackend_Qiniu{}
mi := &file_conf_conf_proto_msgTypes[13]
mi := &file_conf_conf_proto_msgTypes[15]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -975,7 +1127,7 @@ func (x *AdminBackend_Qiniu) String() string {
func (*AdminBackend_Qiniu) ProtoMessage() {}
func (x *AdminBackend_Qiniu) ProtoReflect() protoreflect.Message {
mi := &file_conf_conf_proto_msgTypes[13]
mi := &file_conf_conf_proto_msgTypes[15]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -988,7 +1140,7 @@ func (x *AdminBackend_Qiniu) ProtoReflect() protoreflect.Message {
// Deprecated: Use AdminBackend_Qiniu.ProtoReflect.Descriptor instead.
func (*AdminBackend_Qiniu) Descriptor() ([]byte, []int) {
return file_conf_conf_proto_rawDescGZIP(), []int{3, 6}
return file_conf_conf_proto_rawDescGZIP(), []int{3, 8}
}
func (x *AdminBackend_Qiniu) GetZone() string {
@@ -1060,7 +1212,7 @@ type AdminBackend_ObjectStore struct {
func (x *AdminBackend_ObjectStore) Reset() {
*x = AdminBackend_ObjectStore{}
mi := &file_conf_conf_proto_msgTypes[14]
mi := &file_conf_conf_proto_msgTypes[16]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1072,7 +1224,7 @@ func (x *AdminBackend_ObjectStore) String() string {
func (*AdminBackend_ObjectStore) ProtoMessage() {}
func (x *AdminBackend_ObjectStore) ProtoReflect() protoreflect.Message {
mi := &file_conf_conf_proto_msgTypes[14]
mi := &file_conf_conf_proto_msgTypes[16]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1085,7 +1237,7 @@ func (x *AdminBackend_ObjectStore) ProtoReflect() protoreflect.Message {
// Deprecated: Use AdminBackend_ObjectStore.ProtoReflect.Descriptor instead.
func (*AdminBackend_ObjectStore) Descriptor() ([]byte, []int) {
return file_conf_conf_proto_rawDescGZIP(), []int{3, 7}
return file_conf_conf_proto_rawDescGZIP(), []int{3, 9}
}
func (x *AdminBackend_ObjectStore) GetEndpoint() string {
@@ -1173,10 +1325,11 @@ const file_conf_conf_proto_rawDesc = "" +
"\x04HTTP\x12\x18\n" +
"\anetwork\x18\x01 \x01(\tR\anetwork\x12\x12\n" +
"\x04addr\x18\x02 \x01(\tR\x04addr\x123\n" +
"\atimeout\x18\x03 \x01(\v2\x19.google.protobuf.DurationR\atimeout\"\xf6\x03\n" +
"\atimeout\x18\x03 \x01(\v2\x19.google.protobuf.DurationR\atimeout\"\xef\x04\n" +
"\x04Data\x125\n" +
"\bdatabase\x18\x01 \x01(\v2\x19.kratos.api.Data.DatabaseR\bdatabase\x12,\n" +
"\x05redis\x18\x02 \x01(\v2\x16.kratos.api.Data.RedisR\x05redis\x1a\xd2\x01\n" +
"\x05redis\x18\x02 \x01(\v2\x16.kratos.api.Data.RedisR\x05redis\x12>\n" +
"\rdatabase_list\x18\x03 \x03(\v2\x19.kratos.api.Data.DatabaseR\fdatabaseList\x1a\x8b\x02\n" +
"\bDatabase\x12\x16\n" +
"\x06driver\x18\x01 \x01(\tR\x06driver\x12\x16\n" +
"\x06source\x18\x02 \x01(\tR\x06source\x12\x12\n" +
@@ -1186,12 +1339,16 @@ const file_conf_conf_proto_rawDesc = "" +
"\bpassword\x18\x06 \x01(\tR\bpassword\x12\x12\n" +
"\x04name\x18\a \x01(\tR\x04name\x12\x16\n" +
"\x06config\x18\b \x01(\tR\x06config\x12\x12\n" +
"\x04path\x18\t \x01(\tR\x04path\x1a\xb3\x01\n" +
"\x04path\x18\t \x01(\tR\x04path\x12\x1d\n" +
"\n" +
"alias_name\x18\n" +
" \x01(\tR\taliasName\x12\x18\n" +
"\adisable\x18\v \x01(\bR\adisable\x1a\xb3\x01\n" +
"\x05Redis\x12\x18\n" +
"\anetwork\x18\x01 \x01(\tR\anetwork\x12\x12\n" +
"\x04addr\x18\x02 \x01(\tR\x04addr\x12<\n" +
"\fread_timeout\x18\x03 \x01(\v2\x19.google.protobuf.DurationR\vreadTimeout\x12>\n" +
"\rwrite_timeout\x18\x04 \x01(\v2\x19.google.protobuf.DurationR\fwriteTimeout\"\xb1\x10\n" +
"\rwrite_timeout\x18\x04 \x01(\v2\x19.google.protobuf.DurationR\fwriteTimeout\"\xf8\x12\n" +
"\fAdminBackend\x12#\n" +
"\rrouter_prefix\x18\x01 \x01(\tR\frouterPrefix\x12.\n" +
"\x03jwt\x18\x02 \x01(\v2\x1c.kratos.api.AdminBackend.JWTR\x03jwt\x12:\n" +
@@ -1201,7 +1358,10 @@ const file_conf_conf_proto_rawDesc = "" +
"\astorage\x18\x06 \x01(\v2 .kratos.api.AdminBackend.StorageR\astorage\x12\x1f\n" +
"\vconfig_path\x18\a \x01(\tR\n" +
"configPath\x124\n" +
"\x05media\x18\b \x01(\v2\x1e.kratos.api.AdminBackend.MediaR\x05media\x1a\xb8\x01\n" +
"\x05media\x18\b \x01(\v2\x1e.kratos.api.AdminBackend.MediaR\x05media\x12:\n" +
"\tdisk_list\x18\t \x03(\v2\x1d.kratos.api.AdminBackend.DiskR\bdiskList\x127\n" +
"\x06system\x18\n" +
" \x01(\v2\x1f.kratos.api.AdminBackend.SystemR\x06system\x1a\xb8\x01\n" +
"\x03JWT\x12\x1f\n" +
"\vsigning_key\x18\x01 \x01(\tR\n" +
"signingKey\x12<\n" +
@@ -1231,7 +1391,15 @@ const file_conf_conf_proto_rawDesc = "" +
"\ris_login_auth\x18\b \x01(\bR\visLoginAuth\x1a(\n" +
"\x05Media\x12\x1f\n" +
"\vsession_ttl\x18\x01 \x01(\x05R\n" +
"sessionTtl\x1a\xe8\x03\n" +
"sessionTtl\x1a'\n" +
"\x04Disk\x12\x1f\n" +
"\vmount_point\x18\x01 \x01(\tR\n" +
"mountPoint\x1a\xa6\x01\n" +
"\x06System\x12\x1b\n" +
"\tuse_redis\x18\x01 \x01(\bR\buseRedis\x12%\n" +
"\x0euse_multipoint\x18\x02 \x01(\bR\ruseMultipoint\x12&\n" +
"\x0fuse_strict_auth\x18\x03 \x01(\bR\ruseStrictAuth\x120\n" +
"\x14disable_auto_migrate\x18\x04 \x01(\bR\x12disableAutoMigrate\x1a\xe8\x03\n" +
"\aStorage\x12\x12\n" +
"\x04type\x18\x01 \x01(\tR\x04type\x124\n" +
"\x05qiniu\x18\x02 \x01(\v2\x1e.kratos.api.AdminBackend.QiniuR\x05qiniu\x12C\n" +
@@ -1283,7 +1451,7 @@ func file_conf_conf_proto_rawDescGZIP() []byte {
return file_conf_conf_proto_rawDescData
}
var file_conf_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
var file_conf_conf_proto_msgTypes = make([]protoimpl.MessageInfo, 17)
var file_conf_conf_proto_goTypes = []any{
(*Bootstrap)(nil), // 0: kratos.api.Bootstrap
(*Server)(nil), // 1: kratos.api.Server
@@ -1297,10 +1465,12 @@ var file_conf_conf_proto_goTypes = []any{
(*AdminBackend_Local)(nil), // 9: kratos.api.AdminBackend.Local
(*AdminBackend_Email)(nil), // 10: kratos.api.AdminBackend.Email
(*AdminBackend_Media)(nil), // 11: kratos.api.AdminBackend.Media
(*AdminBackend_Storage)(nil), // 12: kratos.api.AdminBackend.Storage
(*AdminBackend_Qiniu)(nil), // 13: kratos.api.AdminBackend.Qiniu
(*AdminBackend_ObjectStore)(nil), // 14: kratos.api.AdminBackend.ObjectStore
(*durationpb.Duration)(nil), // 15: google.protobuf.Duration
(*AdminBackend_Disk)(nil), // 12: kratos.api.AdminBackend.Disk
(*AdminBackend_System)(nil), // 13: kratos.api.AdminBackend.System
(*AdminBackend_Storage)(nil), // 14: kratos.api.AdminBackend.Storage
(*AdminBackend_Qiniu)(nil), // 15: kratos.api.AdminBackend.Qiniu
(*AdminBackend_ObjectStore)(nil), // 16: kratos.api.AdminBackend.ObjectStore
(*durationpb.Duration)(nil), // 17: google.protobuf.Duration
}
var file_conf_conf_proto_depIdxs = []int32{
1, // 0: kratos.api.Bootstrap.server:type_name -> kratos.api.Server
@@ -1309,30 +1479,33 @@ var file_conf_conf_proto_depIdxs = []int32{
4, // 3: kratos.api.Server.http:type_name -> kratos.api.Server.HTTP
5, // 4: kratos.api.Data.database:type_name -> kratos.api.Data.Database
6, // 5: kratos.api.Data.redis:type_name -> kratos.api.Data.Redis
7, // 6: kratos.api.AdminBackend.jwt:type_name -> kratos.api.AdminBackend.JWT
8, // 7: kratos.api.AdminBackend.captcha:type_name -> kratos.api.AdminBackend.Captcha
9, // 8: kratos.api.AdminBackend.local:type_name -> kratos.api.AdminBackend.Local
10, // 9: kratos.api.AdminBackend.email:type_name -> kratos.api.AdminBackend.Email
12, // 10: kratos.api.AdminBackend.storage:type_name -> kratos.api.AdminBackend.Storage
11, // 11: kratos.api.AdminBackend.media:type_name -> kratos.api.AdminBackend.Media
15, // 12: kratos.api.Server.HTTP.timeout:type_name -> google.protobuf.Duration
15, // 13: kratos.api.Data.Redis.read_timeout:type_name -> google.protobuf.Duration
15, // 14: kratos.api.Data.Redis.write_timeout:type_name -> google.protobuf.Duration
15, // 15: kratos.api.AdminBackend.JWT.expires_time:type_name -> google.protobuf.Duration
15, // 16: kratos.api.AdminBackend.JWT.buffer_time:type_name -> google.protobuf.Duration
15, // 17: kratos.api.AdminBackend.Captcha.store_expiration:type_name -> google.protobuf.Duration
13, // 18: kratos.api.AdminBackend.Storage.qiniu:type_name -> kratos.api.AdminBackend.Qiniu
14, // 19: kratos.api.AdminBackend.Storage.aliyun_oss:type_name -> kratos.api.AdminBackend.ObjectStore
14, // 20: kratos.api.AdminBackend.Storage.huawei_obs:type_name -> kratos.api.AdminBackend.ObjectStore
14, // 21: kratos.api.AdminBackend.Storage.tencent_cos:type_name -> kratos.api.AdminBackend.ObjectStore
14, // 22: kratos.api.AdminBackend.Storage.aws_s3:type_name -> kratos.api.AdminBackend.ObjectStore
14, // 23: kratos.api.AdminBackend.Storage.cloudflare_r2:type_name -> kratos.api.AdminBackend.ObjectStore
14, // 24: kratos.api.AdminBackend.Storage.minio:type_name -> kratos.api.AdminBackend.ObjectStore
25, // [25:25] is the sub-list for method output_type
25, // [25:25] is the sub-list for method input_type
25, // [25:25] is the sub-list for extension type_name
25, // [25:25] is the sub-list for extension extendee
0, // [0:25] is the sub-list for field type_name
5, // 6: kratos.api.Data.database_list:type_name -> kratos.api.Data.Database
7, // 7: kratos.api.AdminBackend.jwt:type_name -> kratos.api.AdminBackend.JWT
8, // 8: kratos.api.AdminBackend.captcha:type_name -> kratos.api.AdminBackend.Captcha
9, // 9: kratos.api.AdminBackend.local:type_name -> kratos.api.AdminBackend.Local
10, // 10: kratos.api.AdminBackend.email:type_name -> kratos.api.AdminBackend.Email
14, // 11: kratos.api.AdminBackend.storage:type_name -> kratos.api.AdminBackend.Storage
11, // 12: kratos.api.AdminBackend.media:type_name -> kratos.api.AdminBackend.Media
12, // 13: kratos.api.AdminBackend.disk_list:type_name -> kratos.api.AdminBackend.Disk
13, // 14: kratos.api.AdminBackend.system:type_name -> kratos.api.AdminBackend.System
17, // 15: kratos.api.Server.HTTP.timeout:type_name -> google.protobuf.Duration
17, // 16: kratos.api.Data.Redis.read_timeout:type_name -> google.protobuf.Duration
17, // 17: kratos.api.Data.Redis.write_timeout:type_name -> google.protobuf.Duration
17, // 18: kratos.api.AdminBackend.JWT.expires_time:type_name -> google.protobuf.Duration
17, // 19: kratos.api.AdminBackend.JWT.buffer_time:type_name -> google.protobuf.Duration
17, // 20: kratos.api.AdminBackend.Captcha.store_expiration:type_name -> google.protobuf.Duration
15, // 21: kratos.api.AdminBackend.Storage.qiniu:type_name -> kratos.api.AdminBackend.Qiniu
16, // 22: kratos.api.AdminBackend.Storage.aliyun_oss:type_name -> kratos.api.AdminBackend.ObjectStore
16, // 23: kratos.api.AdminBackend.Storage.huawei_obs:type_name -> kratos.api.AdminBackend.ObjectStore
16, // 24: kratos.api.AdminBackend.Storage.tencent_cos:type_name -> kratos.api.AdminBackend.ObjectStore
16, // 25: kratos.api.AdminBackend.Storage.aws_s3:type_name -> kratos.api.AdminBackend.ObjectStore
16, // 26: kratos.api.AdminBackend.Storage.cloudflare_r2:type_name -> kratos.api.AdminBackend.ObjectStore
16, // 27: kratos.api.AdminBackend.Storage.minio:type_name -> kratos.api.AdminBackend.ObjectStore
28, // [28:28] is the sub-list for method output_type
28, // [28:28] is the sub-list for method input_type
28, // [28:28] is the sub-list for extension type_name
28, // [28:28] is the sub-list for extension extendee
0, // [0:28] is the sub-list for field type_name
}
func init() { file_conf_conf_proto_init() }
@@ -1346,7 +1519,7 @@ func file_conf_conf_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_conf_conf_proto_rawDesc), len(file_conf_conf_proto_rawDesc)),
NumEnums: 0,
NumMessages: 15,
NumMessages: 17,
NumExtensions: 0,
NumServices: 0,
},
+16
View File
@@ -31,6 +31,8 @@ message Data {
string name = 7;
string config = 8;
string path = 9;
string alias_name = 10;
bool disable = 11;
}
message Redis {
string network = 1;
@@ -40,6 +42,7 @@ message Data {
}
Database database = 1;
Redis redis = 2;
repeated Database database_list = 3;
}
// AdminBackend contains settings for the administration HTTP transport.
@@ -53,6 +56,8 @@ message AdminBackend {
// ConfigPath is populated by the entrypoint and is not required in YAML.
string config_path = 7;
Media media = 8;
repeated Disk disk_list = 9;
System system = 10;
message JWT {
string signing_key = 1;
@@ -88,6 +93,17 @@ message AdminBackend {
int32 session_ttl = 1;
}
message Disk {
string mount_point = 1;
}
message System {
bool use_redis = 1;
bool use_multipoint = 2;
bool use_strict_auth = 3;
bool disable_auto_migrate = 4;
}
message Storage {
string type = 1;
Qiniu qiniu = 2;
+94
View File
@@ -0,0 +1,94 @@
package conf
import (
"sync/atomic"
"google.golang.org/protobuf/proto"
)
// Runtime owns the active immutable configuration snapshot. Callers always
// receive clones so a config file reload cannot race with request handling.
type Runtime struct {
snapshot atomic.Pointer[runtimeSnapshot]
}
type runtimeSnapshot struct {
data *Data
admin *AdminBackend
}
func NewRuntime(data *Data, admin *AdminBackend) *Runtime {
runtime := &Runtime{}
runtime.Replace(data, admin)
return runtime
}
func cloneData(value *Data) *Data {
if value == nil {
return nil
}
return proto.Clone(value).(*Data)
}
func cloneAdmin(value *AdminBackend) *AdminBackend {
if value == nil {
return nil
}
return proto.Clone(value).(*AdminBackend)
}
func (r *Runtime) Replace(data *Data, admin *AdminBackend) {
r.snapshot.Store(&runtimeSnapshot{data: cloneData(data), admin: cloneAdmin(admin)})
}
func (r *Runtime) Data() *Data {
snapshot := r.snapshot.Load()
if snapshot == nil {
return nil
}
return cloneData(snapshot.data)
}
func (r *Runtime) Admin() *AdminBackend {
snapshot := r.snapshot.Load()
if snapshot == nil {
return nil
}
return cloneAdmin(snapshot.admin)
}
func (r *Runtime) Values() (*Data, *AdminBackend) {
snapshot := r.snapshot.Load()
if snapshot == nil {
return nil, nil
}
return cloneData(snapshot.data), cloneAdmin(snapshot.admin)
}
func (r *Runtime) ConfigPath() string {
snapshot := r.snapshot.Load()
if snapshot == nil || snapshot.admin == nil {
return ""
}
return snapshot.admin.ConfigPath
}
func (r *Runtime) UpdateDatabase(database *Data_Database) {
for {
current := r.snapshot.Load()
var data *Data
var admin *AdminBackend
if current != nil {
data = cloneData(current.data)
admin = cloneAdmin(current.admin)
}
if data == nil {
data = &Data{}
}
data.Database = proto.Clone(database).(*Data_Database)
next := &runtimeSnapshot{data: data, admin: admin}
if r.snapshot.CompareAndSwap(current, next) {
return
}
}
}
+41
View File
@@ -0,0 +1,41 @@
package conf
import (
"sync"
"testing"
)
func TestRuntimeSnapshotsAreImmutable(t *testing.T) {
runtime := NewRuntime(&Data{Database: &Data_Database{Name: "first"}}, &AdminBackend{RouterPrefix: "/api", Jwt: &AdminBackend_JWT{SigningKey: "secret"}})
admin := runtime.Admin()
admin.RouterPrefix = "/changed"
admin.Jwt.SigningKey = "changed"
data := runtime.Data()
data.Database.Name = "changed"
if got := runtime.Admin(); got.RouterPrefix != "/api" || got.Jwt.SigningKey != "secret" {
t.Fatalf("admin snapshot mutated: %+v", got)
}
if got := runtime.Data().Database.Name; got != "first" {
t.Fatalf("data snapshot mutated: %s", got)
}
}
func TestRuntimeConcurrentReplaceAndRead(t *testing.T) {
runtime := NewRuntime(&Data{Database: &Data_Database{Name: "initial"}}, &AdminBackend{Jwt: &AdminBackend_JWT{SigningKey: "initial"}})
var wait sync.WaitGroup
for worker := 0; worker < 8; worker++ {
wait.Add(1)
go func() {
defer wait.Done()
for index := 0; index < 500; index++ {
_ = runtime.Admin().Jwt.SigningKey
_ = runtime.Data().Database.Name
}
}()
}
for index := 0; index < 500; index++ {
runtime.Replace(&Data{Database: &Data_Database{Name: "next"}}, &AdminBackend{Jwt: &AdminBackend_JWT{SigningKey: "next"}})
}
wait.Wait()
}