summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortsmax2004 <[email protected]>2023-09-29 16:43:57 +0300
committertsmax2004 <[email protected]>2023-09-29 17:15:14 +0300
commit93fa7ac68f02e9049807270c7c3970782497a69c (patch)
tree0250bf01bd1e40bb7576cc546b0567d26ce39c3d
parent260dcc87e78bd992a11c989f99e0b5f646739a16 (diff)
YQ Connector: Configuration of logging level
add ability to config level of server logging
-rw-r--r--ydb/library/yql/providers/generic/connector/app/client/client.go10
-rw-r--r--ydb/library/yql/providers/generic/connector/app/config/server.pb.go301
-rw-r--r--ydb/library/yql/providers/generic/connector/app/config/server.proto28
-rw-r--r--ydb/library/yql/providers/generic/connector/app/server/config.go10
-rw-r--r--ydb/library/yql/providers/generic/connector/app/server/server.go14
-rw-r--r--ydb/library/yql/providers/generic/connector/app/server/utils/logger.go37
-rw-r--r--ydb/library/yql/providers/generic/connector/app/server/utils/read_limiter.go4
7 files changed, 299 insertions, 105 deletions
diff --git a/ydb/library/yql/providers/generic/connector/app/client/client.go b/ydb/library/yql/providers/generic/connector/app/client/client.go
index 9291fbb1f9e..1318625ba8d 100644
--- a/ydb/library/yql/providers/generic/connector/app/client/client.go
+++ b/ydb/library/yql/providers/generic/connector/app/client/client.go
@@ -45,11 +45,6 @@ func newConfigFromPath(configPath string) (*config.ClientConfig, error) {
}
func runClient(_ *cobra.Command, args []string) error {
- logger, err := utils.NewDevelopmentLogger()
- if err != nil {
- return fmt.Errorf("zap new: %w", err)
- }
-
configPath := args[0]
cfg, err := newConfigFromPath(configPath)
@@ -57,6 +52,11 @@ func runClient(_ *cobra.Command, args []string) error {
return fmt.Errorf("unknown instance: %w", err)
}
+ logger, err := utils.NewDefaultLogger()
+ if err != nil {
+ return fmt.Errorf("new default logger: %w", err)
+ }
+
if err := callServer(logger, cfg); err != nil {
return fmt.Errorf("call server: %w", err)
}
diff --git a/ydb/library/yql/providers/generic/connector/app/config/server.pb.go b/ydb/library/yql/providers/generic/connector/app/config/server.pb.go
index 4dd7a97d2bb..fb8f895b6a4 100644
--- a/ydb/library/yql/providers/generic/connector/app/config/server.pb.go
+++ b/ydb/library/yql/providers/generic/connector/app/config/server.pb.go
@@ -21,8 +21,67 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
+// ELogLevel enumerates standard levels of logging
+type ELogLevel int32
+
+const (
+ ELogLevel_TRACE ELogLevel = 0
+ ELogLevel_DEBUG ELogLevel = 1
+ ELogLevel_INFO ELogLevel = 2
+ ELogLevel_WARN ELogLevel = 3
+ ELogLevel_ERROR ELogLevel = 4
+ ELogLevel_FATAL ELogLevel = 5
+)
+
+// Enum value maps for ELogLevel.
+var (
+ ELogLevel_name = map[int32]string{
+ 0: "TRACE",
+ 1: "DEBUG",
+ 2: "INFO",
+ 3: "WARN",
+ 4: "ERROR",
+ 5: "FATAL",
+ }
+ ELogLevel_value = map[string]int32{
+ "TRACE": 0,
+ "DEBUG": 1,
+ "INFO": 2,
+ "WARN": 3,
+ "ERROR": 4,
+ "FATAL": 5,
+ }
+)
+
+func (x ELogLevel) Enum() *ELogLevel {
+ p := new(ELogLevel)
+ *p = x
+ return p
+}
+
+func (x ELogLevel) String() string {
+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
+}
+
+func (ELogLevel) Descriptor() protoreflect.EnumDescriptor {
+ return file_ydb_library_yql_providers_generic_connector_app_config_server_proto_enumTypes[0].Descriptor()
+}
+
+func (ELogLevel) Type() protoreflect.EnumType {
+ return &file_ydb_library_yql_providers_generic_connector_app_config_server_proto_enumTypes[0]
+}
+
+func (x ELogLevel) Number() protoreflect.EnumNumber {
+ return protoreflect.EnumNumber(x)
+}
+
+// Deprecated: Use ELogLevel.Descriptor instead.
+func (ELogLevel) EnumDescriptor() ([]byte, []int) {
+ return file_ydb_library_yql_providers_generic_connector_app_config_server_proto_rawDescGZIP(), []int{0}
+}
+
// Connector server configuration
-type ServerConfig struct {
+type TServerConfig struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
@@ -31,15 +90,17 @@ type ServerConfig struct {
Endpoint *common.TEndpoint `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
// TLS settings.
// Leave it empty for insecure connections.
- Tls *ServerTLSConfig `protobuf:"bytes,2,opt,name=tls,proto3" json:"tls,omitempty"`
+ Tls *TServerTLSConfig `protobuf:"bytes,2,opt,name=tls,proto3" json:"tls,omitempty"`
// This is a rough restriction for YQ memory consumption until
// https://st.yandex-team.ru/YQ-2057 is implemented.
// Leave it empty if you want to avoid any memory limits.
- ReadLimit *ServerReadLimit `protobuf:"bytes,3,opt,name=read_limit,json=readLimit,proto3" json:"read_limit,omitempty"`
+ ReadLimit *TServerReadLimit `protobuf:"bytes,3,opt,name=read_limit,json=readLimit,proto3" json:"read_limit,omitempty"`
+ // Logger config
+ Logger *TLoggerConfig `protobuf:"bytes,4,opt,name=logger,proto3" json:"logger,omitempty"`
}
-func (x *ServerConfig) Reset() {
- *x = ServerConfig{}
+func (x *TServerConfig) Reset() {
+ *x = TServerConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -47,13 +108,13 @@ func (x *ServerConfig) Reset() {
}
}
-func (x *ServerConfig) String() string {
+func (x *TServerConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*ServerConfig) ProtoMessage() {}
+func (*TServerConfig) ProtoMessage() {}
-func (x *ServerConfig) ProtoReflect() protoreflect.Message {
+func (x *TServerConfig) ProtoReflect() protoreflect.Message {
mi := &file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -65,33 +126,40 @@ func (x *ServerConfig) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use ServerConfig.ProtoReflect.Descriptor instead.
-func (*ServerConfig) Descriptor() ([]byte, []int) {
+// Deprecated: Use TServerConfig.ProtoReflect.Descriptor instead.
+func (*TServerConfig) Descriptor() ([]byte, []int) {
return file_ydb_library_yql_providers_generic_connector_app_config_server_proto_rawDescGZIP(), []int{0}
}
-func (x *ServerConfig) GetEndpoint() *common.TEndpoint {
+func (x *TServerConfig) GetEndpoint() *common.TEndpoint {
if x != nil {
return x.Endpoint
}
return nil
}
-func (x *ServerConfig) GetTls() *ServerTLSConfig {
+func (x *TServerConfig) GetTls() *TServerTLSConfig {
if x != nil {
return x.Tls
}
return nil
}
-func (x *ServerConfig) GetReadLimit() *ServerReadLimit {
+func (x *TServerConfig) GetReadLimit() *TServerReadLimit {
if x != nil {
return x.ReadLimit
}
return nil
}
-type ServerTLSConfig struct {
+func (x *TServerConfig) GetLogger() *TLoggerConfig {
+ if x != nil {
+ return x.Logger
+ }
+ return nil
+}
+
+type TServerTLSConfig struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
@@ -102,8 +170,8 @@ type ServerTLSConfig struct {
Cert string `protobuf:"bytes,3,opt,name=cert,proto3" json:"cert,omitempty"`
}
-func (x *ServerTLSConfig) Reset() {
- *x = ServerTLSConfig{}
+func (x *TServerTLSConfig) Reset() {
+ *x = TServerTLSConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -111,13 +179,13 @@ func (x *ServerTLSConfig) Reset() {
}
}
-func (x *ServerTLSConfig) String() string {
+func (x *TServerTLSConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*ServerTLSConfig) ProtoMessage() {}
+func (*TServerTLSConfig) ProtoMessage() {}
-func (x *ServerTLSConfig) ProtoReflect() protoreflect.Message {
+func (x *TServerTLSConfig) ProtoReflect() protoreflect.Message {
mi := &file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -129,19 +197,19 @@ func (x *ServerTLSConfig) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use ServerTLSConfig.ProtoReflect.Descriptor instead.
-func (*ServerTLSConfig) Descriptor() ([]byte, []int) {
+// Deprecated: Use TServerTLSConfig.ProtoReflect.Descriptor instead.
+func (*TServerTLSConfig) Descriptor() ([]byte, []int) {
return file_ydb_library_yql_providers_generic_connector_app_config_server_proto_rawDescGZIP(), []int{1}
}
-func (x *ServerTLSConfig) GetKey() string {
+func (x *TServerTLSConfig) GetKey() string {
if x != nil {
return x.Key
}
return ""
}
-func (x *ServerTLSConfig) GetCert() string {
+func (x *TServerTLSConfig) GetCert() string {
if x != nil {
return x.Cert
}
@@ -149,7 +217,7 @@ func (x *ServerTLSConfig) GetCert() string {
}
// ServerReadLimit limitates the amount of data extracted from the data source on every read request.
-type ServerReadLimit struct {
+type TServerReadLimit struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
@@ -158,8 +226,8 @@ type ServerReadLimit struct {
Rows uint64 `protobuf:"varint,1,opt,name=rows,proto3" json:"rows,omitempty"`
}
-func (x *ServerReadLimit) Reset() {
- *x = ServerReadLimit{}
+func (x *TServerReadLimit) Reset() {
+ *x = TServerReadLimit{}
if protoimpl.UnsafeEnabled {
mi := &file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -167,13 +235,13 @@ func (x *ServerReadLimit) Reset() {
}
}
-func (x *ServerReadLimit) String() string {
+func (x *TServerReadLimit) String() string {
return protoimpl.X.MessageStringOf(x)
}
-func (*ServerReadLimit) ProtoMessage() {}
+func (*TServerReadLimit) ProtoMessage() {}
-func (x *ServerReadLimit) ProtoReflect() protoreflect.Message {
+func (x *TServerReadLimit) ProtoReflect() protoreflect.Message {
mi := &file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -185,18 +253,67 @@ func (x *ServerReadLimit) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x)
}
-// Deprecated: Use ServerReadLimit.ProtoReflect.Descriptor instead.
-func (*ServerReadLimit) Descriptor() ([]byte, []int) {
+// Deprecated: Use TServerReadLimit.ProtoReflect.Descriptor instead.
+func (*TServerReadLimit) Descriptor() ([]byte, []int) {
return file_ydb_library_yql_providers_generic_connector_app_config_server_proto_rawDescGZIP(), []int{2}
}
-func (x *ServerReadLimit) GetRows() uint64 {
+func (x *TServerReadLimit) GetRows() uint64 {
if x != nil {
return x.Rows
}
return 0
}
+// TLogger represents logger configuration
+type TLoggerConfig struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // Level of logging
+ LogLevel ELogLevel `protobuf:"varint,1,opt,name=log_level,json=logLevel,proto3,enum=NYql.Connector.App.Config.ELogLevel" json:"log_level,omitempty"`
+}
+
+func (x *TLoggerConfig) Reset() {
+ *x = TLoggerConfig{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[3]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *TLoggerConfig) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*TLoggerConfig) ProtoMessage() {}
+
+func (x *TLoggerConfig) ProtoReflect() protoreflect.Message {
+ mi := &file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[3]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use TLoggerConfig.ProtoReflect.Descriptor instead.
+func (*TLoggerConfig) Descriptor() ([]byte, []int) {
+ return file_ydb_library_yql_providers_generic_connector_app_config_server_proto_rawDescGZIP(), []int{3}
+}
+
+func (x *TLoggerConfig) GetLogLevel() ELogLevel {
+ if x != nil {
+ return x.LogLevel
+ }
+ return ELogLevel_TRACE
+}
+
var File_ydb_library_yql_providers_generic_connector_app_config_server_proto protoreflect.FileDescriptor
var file_ydb_library_yql_providers_generic_connector_app_config_server_proto_rawDesc = []byte{
@@ -210,32 +327,46 @@ var file_ydb_library_yql_providers_generic_connector_app_config_server_proto_raw
0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2f, 0x67, 0x65, 0x6e, 0x65,
0x72, 0x69, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2f, 0x61, 0x70,
0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e,
- 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd4, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76,
- 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70,
- 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x4e, 0x59, 0x71,
- 0x6c, 0x2e, 0x4e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x4e, 0x41, 0x70,
- 0x69, 0x2e, 0x54, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x08, 0x65, 0x6e, 0x64,
- 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x3c, 0x0a, 0x03, 0x74, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x01,
- 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x4e, 0x59, 0x71, 0x6c, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
- 0x74, 0x6f, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x53,
- 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x4c, 0x53, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x03,
- 0x74, 0x6c, 0x73, 0x12, 0x49, 0x0a, 0x0a, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6c, 0x69, 0x6d, 0x69,
- 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x4e, 0x59, 0x71, 0x6c, 0x2e, 0x43,
- 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x43, 0x6f, 0x6e,
- 0x66, 0x69, 0x67, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x4c, 0x69,
- 0x6d, 0x69, 0x74, 0x52, 0x09, 0x72, 0x65, 0x61, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x22, 0x3d,
- 0x0a, 0x0f, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x4c, 0x53, 0x43, 0x6f, 0x6e, 0x66, 0x69,
- 0x67, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
- 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x65, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
- 0x09, 0x52, 0x04, 0x63, 0x65, 0x72, 0x74, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x22, 0x25, 0x0a,
- 0x0f, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74,
- 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04,
- 0x72, 0x6f, 0x77, 0x73, 0x42, 0x49, 0x5a, 0x47, 0x61, 0x2e, 0x79, 0x61, 0x6e, 0x64, 0x65, 0x78,
- 0x2d, 0x74, 0x65, 0x61, 0x6d, 0x2e, 0x72, 0x75, 0x2f, 0x79, 0x64, 0x62, 0x2f, 0x6c, 0x69, 0x62,
- 0x72, 0x61, 0x72, 0x79, 0x2f, 0x79, 0x71, 0x6c, 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65,
- 0x72, 0x73, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x69, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
- 0x63, 0x74, 0x6f, 0x72, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x62,
- 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x99, 0x02, 0x0a, 0x0d, 0x54, 0x53, 0x65, 0x72,
+ 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, 0x08, 0x65, 0x6e, 0x64,
+ 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x4e, 0x59,
+ 0x71, 0x6c, 0x2e, 0x4e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x4e, 0x41,
+ 0x70, 0x69, 0x2e, 0x54, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x08, 0x65, 0x6e,
+ 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x3d, 0x0a, 0x03, 0x74, 0x6c, 0x73, 0x18, 0x02, 0x20,
+ 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x4e, 0x59, 0x71, 0x6c, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65,
+ 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e,
+ 0x54, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x4c, 0x53, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
+ 0x52, 0x03, 0x74, 0x6c, 0x73, 0x12, 0x4a, 0x0a, 0x0a, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x6c, 0x69,
+ 0x6d, 0x69, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x4e, 0x59, 0x71, 0x6c,
+ 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x43,
+ 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65, 0x61,
+ 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x09, 0x72, 0x65, 0x61, 0x64, 0x4c, 0x69, 0x6d, 0x69,
+ 0x74, 0x12, 0x40, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28,
+ 0x0b, 0x32, 0x28, 0x2e, 0x4e, 0x59, 0x71, 0x6c, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
+ 0x6f, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x4c,
+ 0x6f, 0x67, 0x67, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x06, 0x6c, 0x6f, 0x67,
+ 0x67, 0x65, 0x72, 0x22, 0x3e, 0x0a, 0x10, 0x54, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x4c,
+ 0x53, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02,
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x65, 0x72,
+ 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x65, 0x72, 0x74, 0x4a, 0x04, 0x08,
+ 0x01, 0x10, 0x02, 0x22, 0x26, 0x0a, 0x10, 0x54, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x65,
+ 0x61, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x18,
+ 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x72, 0x6f, 0x77, 0x73, 0x22, 0x52, 0x0a, 0x0d, 0x54,
+ 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x41, 0x0a, 0x09,
+ 0x6c, 0x6f, 0x67, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32,
+ 0x24, 0x2e, 0x4e, 0x59, 0x71, 0x6c, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x6f, 0x72,
+ 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x45, 0x4c, 0x6f, 0x67,
+ 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x08, 0x6c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x2a,
+ 0x4b, 0x0a, 0x09, 0x45, 0x4c, 0x6f, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x09, 0x0a, 0x05,
+ 0x54, 0x52, 0x41, 0x43, 0x45, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x44, 0x45, 0x42, 0x55, 0x47,
+ 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04,
+ 0x57, 0x41, 0x52, 0x4e, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10,
+ 0x04, 0x12, 0x09, 0x0a, 0x05, 0x46, 0x41, 0x54, 0x41, 0x4c, 0x10, 0x05, 0x42, 0x49, 0x5a, 0x47,
+ 0x61, 0x2e, 0x79, 0x61, 0x6e, 0x64, 0x65, 0x78, 0x2d, 0x74, 0x65, 0x61, 0x6d, 0x2e, 0x72, 0x75,
+ 0x2f, 0x79, 0x64, 0x62, 0x2f, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x2f, 0x79, 0x71, 0x6c,
+ 0x2f, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x73, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x72,
+ 0x69, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2f, 0x61, 0x70, 0x70,
+ 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -250,22 +381,27 @@ func file_ydb_library_yql_providers_generic_connector_app_config_server_proto_ra
return file_ydb_library_yql_providers_generic_connector_app_config_server_proto_rawDescData
}
-var file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
+var file_ydb_library_yql_providers_generic_connector_app_config_server_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
+var file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_ydb_library_yql_providers_generic_connector_app_config_server_proto_goTypes = []interface{}{
- (*ServerConfig)(nil), // 0: NYql.Connector.App.Config.ServerConfig
- (*ServerTLSConfig)(nil), // 1: NYql.Connector.App.Config.ServerTLSConfig
- (*ServerReadLimit)(nil), // 2: NYql.Connector.App.Config.ServerReadLimit
- (*common.TEndpoint)(nil), // 3: NYql.NConnector.NApi.TEndpoint
+ (ELogLevel)(0), // 0: NYql.Connector.App.Config.ELogLevel
+ (*TServerConfig)(nil), // 1: NYql.Connector.App.Config.TServerConfig
+ (*TServerTLSConfig)(nil), // 2: NYql.Connector.App.Config.TServerTLSConfig
+ (*TServerReadLimit)(nil), // 3: NYql.Connector.App.Config.TServerReadLimit
+ (*TLoggerConfig)(nil), // 4: NYql.Connector.App.Config.TLoggerConfig
+ (*common.TEndpoint)(nil), // 5: NYql.NConnector.NApi.TEndpoint
}
var file_ydb_library_yql_providers_generic_connector_app_config_server_proto_depIdxs = []int32{
- 3, // 0: NYql.Connector.App.Config.ServerConfig.endpoint:type_name -> NYql.NConnector.NApi.TEndpoint
- 1, // 1: NYql.Connector.App.Config.ServerConfig.tls:type_name -> NYql.Connector.App.Config.ServerTLSConfig
- 2, // 2: NYql.Connector.App.Config.ServerConfig.read_limit:type_name -> NYql.Connector.App.Config.ServerReadLimit
- 3, // [3:3] is the sub-list for method output_type
- 3, // [3:3] is the sub-list for method input_type
- 3, // [3:3] is the sub-list for extension type_name
- 3, // [3:3] is the sub-list for extension extendee
- 0, // [0:3] is the sub-list for field type_name
+ 5, // 0: NYql.Connector.App.Config.TServerConfig.endpoint:type_name -> NYql.NConnector.NApi.TEndpoint
+ 2, // 1: NYql.Connector.App.Config.TServerConfig.tls:type_name -> NYql.Connector.App.Config.TServerTLSConfig
+ 3, // 2: NYql.Connector.App.Config.TServerConfig.read_limit:type_name -> NYql.Connector.App.Config.TServerReadLimit
+ 4, // 3: NYql.Connector.App.Config.TServerConfig.logger:type_name -> NYql.Connector.App.Config.TLoggerConfig
+ 0, // 4: NYql.Connector.App.Config.TLoggerConfig.log_level:type_name -> NYql.Connector.App.Config.ELogLevel
+ 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
}
func init() { file_ydb_library_yql_providers_generic_connector_app_config_server_proto_init() }
@@ -275,7 +411,7 @@ func file_ydb_library_yql_providers_generic_connector_app_config_server_proto_in
}
if !protoimpl.UnsafeEnabled {
file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*ServerConfig); i {
+ switch v := v.(*TServerConfig); i {
case 0:
return &v.state
case 1:
@@ -287,7 +423,7 @@ func file_ydb_library_yql_providers_generic_connector_app_config_server_proto_in
}
}
file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*ServerTLSConfig); i {
+ switch v := v.(*TServerTLSConfig); i {
case 0:
return &v.state
case 1:
@@ -299,7 +435,19 @@ func file_ydb_library_yql_providers_generic_connector_app_config_server_proto_in
}
}
file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*ServerReadLimit); i {
+ switch v := v.(*TServerReadLimit); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*TLoggerConfig); i {
case 0:
return &v.state
case 1:
@@ -316,13 +464,14 @@ func file_ydb_library_yql_providers_generic_connector_app_config_server_proto_in
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_ydb_library_yql_providers_generic_connector_app_config_server_proto_rawDesc,
- NumEnums: 0,
- NumMessages: 3,
+ NumEnums: 1,
+ NumMessages: 4,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_ydb_library_yql_providers_generic_connector_app_config_server_proto_goTypes,
DependencyIndexes: file_ydb_library_yql_providers_generic_connector_app_config_server_proto_depIdxs,
+ EnumInfos: file_ydb_library_yql_providers_generic_connector_app_config_server_proto_enumTypes,
MessageInfos: file_ydb_library_yql_providers_generic_connector_app_config_server_proto_msgTypes,
}.Build()
File_ydb_library_yql_providers_generic_connector_app_config_server_proto = out.File
diff --git a/ydb/library/yql/providers/generic/connector/app/config/server.proto b/ydb/library/yql/providers/generic/connector/app/config/server.proto
index b7e64593e28..aa71ea677fc 100644
--- a/ydb/library/yql/providers/generic/connector/app/config/server.proto
+++ b/ydb/library/yql/providers/generic/connector/app/config/server.proto
@@ -6,19 +6,21 @@ import "ydb/library/yql/providers/generic/connector/api/common/endpoint.proto";
option go_package = "github.com/ydb-platform/ydb/ydb/library/yql/providers/generic/connector/app/config";
// Connector server configuration
-message ServerConfig {
+message TServerConfig {
// Network address server will be listening on
NYql.NConnector.NApi.TEndpoint endpoint = 1;
// TLS settings.
// Leave it empty for insecure connections.
- ServerTLSConfig tls = 2;
+ TServerTLSConfig tls = 2;
// This is a rough restriction for YQ memory consumption until
// https://st.yandex-team.ru/YQ-2057 is implemented.
// Leave it empty if you want to avoid any memory limits.
- ServerReadLimit read_limit = 3;
+ TServerReadLimit read_limit = 3;
+ // Logger config
+ TLoggerConfig logger = 4;
}
-message ServerTLSConfig {
+message TServerTLSConfig {
// TLS private key path
string key = 2;
// TLS public cert path
@@ -28,7 +30,23 @@ message ServerTLSConfig {
}
// ServerReadLimit limitates the amount of data extracted from the data source on every read request.
-message ServerReadLimit {
+message TServerReadLimit {
// The number of rows extracted from the data source
uint64 rows = 1;
}
+
+// TLogger represents logger configuration
+message TLoggerConfig {
+ // Level of logging
+ ELogLevel log_level = 1;
+}
+
+// ELogLevel enumerates standard levels of logging
+enum ELogLevel {
+ TRACE = 0;
+ DEBUG = 1;
+ INFO = 2;
+ WARN = 3;
+ ERROR = 4;
+ FATAL = 5;
+}
diff --git a/ydb/library/yql/providers/generic/connector/app/server/config.go b/ydb/library/yql/providers/generic/connector/app/server/config.go
index 79098addc71..c6450020d15 100644
--- a/ydb/library/yql/providers/generic/connector/app/server/config.go
+++ b/ydb/library/yql/providers/generic/connector/app/server/config.go
@@ -11,7 +11,7 @@ import (
"google.golang.org/protobuf/encoding/prototext"
)
-func validateServerConfig(c *config.ServerConfig) error {
+func validateServerConfig(c *config.TServerConfig) error {
if err := validateEndpoint(c.Endpoint); err != nil {
return fmt.Errorf("validate `Server`: %w", err)
}
@@ -43,7 +43,7 @@ func validateEndpoint(c *api_common.TEndpoint) error {
return nil
}
-func validateServerTLSConfig(c *config.ServerTLSConfig) error {
+func validateServerTLSConfig(c *config.TServerTLSConfig) error {
if c == nil {
// It's OK not to have TLS config section
return nil
@@ -60,7 +60,7 @@ func validateServerTLSConfig(c *config.ServerTLSConfig) error {
return nil
}
-func validateServerReadLimit(c *config.ServerReadLimit) error {
+func validateServerReadLimit(c *config.TServerReadLimit) error {
if c == nil {
// It's OK not to have read request memory limitation
return nil
@@ -87,13 +87,13 @@ func fileMustExist(path string) error {
return nil
}
-func newConfigFromPath(configPath string) (*config.ServerConfig, error) {
+func newConfigFromPath(configPath string) (*config.TServerConfig, error) {
data, err := ioutil.ReadFile(configPath)
if err != nil {
return nil, fmt.Errorf("read file %v: %w", configPath, err)
}
- var cfg config.ServerConfig
+ var cfg config.TServerConfig
if err := prototext.Unmarshal(data, &cfg); err != nil {
return nil, fmt.Errorf("prototext unmarshal `%v`: %w", string(data), err)
diff --git a/ydb/library/yql/providers/generic/connector/app/server/server.go b/ydb/library/yql/providers/generic/connector/app/server/server.go
index 30deb25ea07..78030729848 100644
--- a/ydb/library/yql/providers/generic/connector/app/server/server.go
+++ b/ydb/library/yql/providers/generic/connector/app/server/server.go
@@ -21,7 +21,7 @@ type Server struct {
api_service.UnimplementedConnectorServer
handlerFactory *rdbms.HandlerFactory
columnarBufferFactory *utils.ColumnarBufferFactory
- cfg *config.ServerConfig
+ cfg *config.TServerConfig
logger log.Logger
}
@@ -260,7 +260,7 @@ func (s *Server) makeOptions() ([]grpc.ServerOption, error) {
func newServer(
logger log.Logger,
- cfg *config.ServerConfig,
+ cfg *config.TServerConfig,
) (*Server, error) {
return &Server{
handlerFactory: rdbms.NewHandlerFactory(),
@@ -274,11 +274,6 @@ func newServer(
}
func runServer(cmd *cobra.Command, _ []string) error {
- logger, err := utils.NewDevelopmentLogger()
- if err != nil {
- return fmt.Errorf("new development logger: %w", err)
- }
-
configPath, err := cmd.Flags().GetString(configFlag)
if err != nil {
return fmt.Errorf("get config flag: %v", err)
@@ -289,6 +284,11 @@ func runServer(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("new config: %w", err)
}
+ logger, err := utils.NewLoggerFromConfig(cfg.Logger)
+ if err != nil {
+ return fmt.Errorf("new logger from config: %w", err)
+ }
+
srv, err := newServer(logger, cfg)
if err != nil {
return fmt.Errorf("new server: %w", err)
diff --git a/ydb/library/yql/providers/generic/connector/app/server/utils/logger.go b/ydb/library/yql/providers/generic/connector/app/server/utils/logger.go
index e3d1c4754b6..f3a281406cb 100644
--- a/ydb/library/yql/providers/generic/connector/app/server/utils/logger.go
+++ b/ydb/library/yql/providers/generic/connector/app/server/utils/logger.go
@@ -8,6 +8,7 @@ import (
"github.com/ydb-platform/ydb/library/go/core/log"
"github.com/ydb-platform/ydb/library/go/core/log/zap"
api_common "github.com/ydb-platform/ydb/ydb/library/yql/providers/generic/connector/api/common"
+ "github.com/ydb-platform/ydb/ydb/library/yql/providers/generic/connector/app/config"
api_service_protos "github.com/ydb-platform/ydb/ydb/library/yql/providers/generic/connector/libgo/service/protos"
"go.uber.org/zap/zapcore"
"go.uber.org/zap/zaptest"
@@ -37,12 +38,17 @@ func LogCloserError(logger log.Logger, closer io.Closer, msg string) {
}
}
-func NewDevelopmentLogger() (log.Logger, error) {
- cfg := zap.NewDeployConfig()
- cfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
- cfg.Encoding = "console"
+func NewLoggerFromConfig(cfg *config.TLoggerConfig) (log.Logger, error) {
+ if cfg == nil {
+ return NewDefaultLogger()
+ }
+
+ loggerCfg := zap.NewDeployConfig()
+ loggerCfg.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
+ loggerCfg.Encoding = "console"
+ loggerCfg.Level.SetLevel(convertToZapLogLevel(cfg.GetLogLevel()))
- zapLogger, err := cfg.Build()
+ zapLogger, err := loggerCfg.Build()
if err != nil {
return nil, fmt.Errorf("new logger: %w", err)
}
@@ -50,6 +56,10 @@ func NewDevelopmentLogger() (log.Logger, error) {
return &zap.Logger{L: zapLogger}, nil
}
+func NewDefaultLogger() (log.Logger, error) {
+ return NewLoggerFromConfig(&config.TLoggerConfig{LogLevel: config.ELogLevel_TRACE})
+}
+
func NewTestLogger(t *testing.T) log.Logger { return &zap.Logger{L: zaptest.NewLogger(t)} }
func DumpReadSplitsResponse(logger log.Logger, resp *api_service_protos.TReadSplitsResponse) {
@@ -68,3 +78,20 @@ func DumpReadSplitsResponse(logger log.Logger, resp *api_service_protos.TReadSpl
logger.Debug("response", log.Int("arrow_blob_length", len(dump)))
}
}
+
+func convertToZapLogLevel(lvl config.ELogLevel) zapcore.Level {
+ switch lvl {
+ case config.ELogLevel_TRACE, config.ELogLevel_DEBUG:
+ return zapcore.DebugLevel
+ case config.ELogLevel_INFO:
+ return zapcore.InfoLevel
+ case config.ELogLevel_WARN:
+ return zapcore.WarnLevel
+ case config.ELogLevel_ERROR:
+ return zapcore.ErrorLevel
+ case config.ELogLevel_FATAL:
+ return zapcore.FatalLevel
+ }
+
+ return zapcore.InvalidLevel
+}
diff --git a/ydb/library/yql/providers/generic/connector/app/server/utils/read_limiter.go b/ydb/library/yql/providers/generic/connector/app/server/utils/read_limiter.go
index 7b9906f21fc..4175b6ec49e 100644
--- a/ydb/library/yql/providers/generic/connector/app/server/utils/read_limiter.go
+++ b/ydb/library/yql/providers/generic/connector/app/server/utils/read_limiter.go
@@ -34,7 +34,7 @@ func (rl *readLimiterRows) AddRow() error {
}
type ReadLimiterFactory struct {
- cfg *config.ServerReadLimit
+ cfg *config.TServerReadLimit
}
func (rlf *ReadLimiterFactory) MakeReadLimiter(logger log.Logger) ReadLimiter {
@@ -47,6 +47,6 @@ func (rlf *ReadLimiterFactory) MakeReadLimiter(logger log.Logger) ReadLimiter {
return &readLimiterRows{rowsRead: 0, rowsLimit: rlf.cfg.GetRows()}
}
-func NewReadLimiterFactory(cfg *config.ServerReadLimit) *ReadLimiterFactory {
+func NewReadLimiterFactory(cfg *config.TServerReadLimit) *ReadLimiterFactory {
return &ReadLimiterFactory{cfg: cfg}
}