diff --git a/pkg/config/client_config.go b/pkg/config/client_config.go deleted file mode 100644 index 4e9ffa8a8..000000000 --- a/pkg/config/client_config.go +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "time" -) - -var clientConfig *ClientConfig - -type ClientConfig struct { - ApplicationID string `yaml:"application_id" json:"application_id,omitempty"` - TransactionServiceGroup string `yaml:"transaction_service_group" json:"transaction_service_group,omitempty"` - EnableClientBatchSendRequest bool `yaml:"enable-rpc_client-batch-send-request" json:"enable-rpc_client-batch-send-request,omitempty"` - SeataVersion string `yaml:"seata_version" json:"seata_version,omitempty"` - GettyConfig GettyConfig `yaml:"getty" json:"getty,omitempty"` - - ATConfig struct { - DSN string `yaml:"dsn" json:"dsn,omitempty"` - ReportRetryCount int `default:"5" yaml:"report_retry_count" json:"report_retry_count,omitempty"` - ReportSuccessEnable bool `default:"false" yaml:"report_success_enable" json:"report_success_enable,omitempty"` - LockRetryInterval time.Duration `default:"10" yaml:"lock_retry_interval" json:"lock_retry_interval,omitempty"` - LockRetryTimes int `default:"30" yaml:"lock_retry_times" json:"lock_retry_times,omitempty"` - } `yaml:"at" json:"at,omitempty"` -} - -func GetClientConfig() *ClientConfig { - return &ClientConfig{ - GettyConfig: GetDefaultGettyConfig(), - } -} - -func GetDefaultClientConfig(applicationID string) *ClientConfig { - return &ClientConfig{ - ApplicationID: applicationID, - TransactionServiceGroup: "127.0.0.1:8091", - EnableClientBatchSendRequest: false, - SeataVersion: "1.1.0", - GettyConfig: GetDefaultGettyConfig(), - } -} - -type Compress struct { - Enable bool `yaml:"enable" json:"enable,omitempty" property:"enable"` - Type string `yaml:"type" json:"type,omitempty" property:"type"` - Threshold int `yaml:"threshold" json:"threshold,omitempty" property:"threshold"` -} - -type Lock struct { - RetryInterval int `yaml:"retry-interval" json:"retry-interval,omitempty" property:"retry-interval"` - RetryTimes time.Duration `yaml:"retry-times" json:"retry-times,omitempty" property:"retry-times"` - RetryPolicyBranchRollbackOnConflict bool `yaml:"retry-policy-branch-rollback-on-conflict" json:"retry-policy-branch-rollback-on-conflict,omitempty" property:"retry-policy-branch-rollback-on-conflict"` -} - -type RmConf struct { - AsyncCommitBufferLimit int `yaml:"async-commit-buffer-limit" json:"async-commit-buffer-limit,omitempty" property:"async-commit-buffer-limit"` - ReportRetryCount int `yaml:"report-retry-count" json:"report-retry-count,omitempty" property:"report-retry-count"` - TableMetaCheckEnable bool `yaml:"table-meta-check-enable" json:"table-meta-check-enable,omitempty" property:"table-meta-check-enable"` - ReportSuccessEnable bool `yaml:"report-success-enable" json:"report-success-enable,omitempty" property:"report-success-enable"` - SagaBranchRegisterEnable bool `yaml:"saga-branch-register-enable" json:"saga-branch-register-enable,omitempty" property:"saga-branch-register-enable"` - SagaJSONParser string `yaml:"saga-json-parser" json:"saga-json-parser,omitempty" property:"saga-json-parser"` - SagaRetryPersistModeUpdate bool `yaml:"saga-retry-persist-mode-update" json:"saga-retry-persist-mode-update,omitempty" property:"saga-retry-persist-mode-update"` - SagaCompensatePersistModeUpdate bool `yaml:"saga-compensate-persist-mode-update" json:"saga-compensate-persist-mode-update,omitempty" property:"saga-compensate-persist-mode-update"` - TccActionInterceptorOrder int `yaml:"tcc-action-interceptor-order" json:"tcc-action-interceptor-order,omitempty" property:"tcc-action-interceptor-order"` - SQLParserType string `yaml:"sql-parser-type" json:"sql-parser-type,omitempty" property:"sql-parser-type"` - Lock Lock `yaml:"lock" json:"lock,omitempty" property:"lock"` -} - -type TmConf struct { - CommitRetryCount int `yaml:"commit-retry-count" json:"commit-retry-count,omitempty" property:"commit-retry-count"` - RollbackRetryCount int `yaml:"rollback-retry-count" json:"rollback-retry-count,omitempty" property:"rollback-retry-count"` - DefaultGlobalTransactionTimeout time.Duration `yaml:"default-global-transaction-timeout" json:"default-global-transaction-timeout,omitempty" property:"default-global-transaction-timeout"` - DegradeCheck bool `yaml:"degrade-check" json:"degrade-check,omitempty" property:"degrade-check"` - DegradeCheckPeriod int `yaml:"degrade-check-period" json:"degrade-check-period,omitempty" property:"degrade-check-period"` - DegradeCheckAllowTimes time.Duration `yaml:"degrade-check-allow-times" json:"degrade-check-allow-times,omitempty" property:"degrade-check-allow-times"` - InterceptorOrder int `yaml:"interceptor-order" json:"interceptor-order,omitempty" property:"interceptor-order"` -} - -type Undo struct { - DataValidation bool `yaml:"data-validation" json:"data-validation,omitempty" property:"data-validation"` - LogSerialization string `yaml:"log-serialization" json:"log-serialization,omitempty" property:"log-serialization"` - LogTable string `yaml:"log-table" json:"log-table,omitempty" property:"log-table"` - OnlyCareUpdateColumns bool `yaml:"only-care-update-columns" json:"only-care-update-columns,omitempty" property:"only-care-update-columns"` - Compress Compress `yaml:"compress" json:"compress,omitempty" property:"compress"` -} - -type LoadBalance struct { - Type string `yaml:"type" json:"type,omitempty" property:"type"` - VirtualNodes int `yaml:"virtual-nodes" json:"virtual-nodes,omitempty" property:"virtual-nodes"` -} - -type ClientConf struct { - Rmconf RmConf `yaml:"rm" json:"rm,omitempty" property:"rm"` - Tmconf TmConf `yaml:"tm" json:"tm,omitempty" property:"tm"` - Undo Undo `yaml:"undo" json:"undo,omitempty" property:"undo"` - LoadBalance LoadBalance `yaml:"load-balance" json:"load-balance,omitempty" property:"load-balance"` -} diff --git a/pkg/config/config_config.go b/pkg/config/config_config.go deleted file mode 100644 index 5693741f4..000000000 --- a/pkg/config/config_config.go +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -type NacosConfig struct { - Namespace string `yaml:"namespace" json:"namespace,omitempty" property:"namespace"` - ServerAddr string `yaml:"server-addr" json:"server-addr,omitempty" property:"server-addr"` - Group string `yaml:"group" json:"group,omitempty" property:"group"` - Username string `yaml:"username" json:"username,omitempty" property:"username"` - Password string `yaml:"password" json:"password,omitempty" property:"password"` - DataID string `yaml:"data-id" json:"data-id,omitempty" property:"data-id"` -} - -// Config is Configuration Center configuration file -type Config struct { - Type string `yaml:"type" json:"type,omitempty" property:"type"` - File File `yaml:"file" json:"file,omitempty" property:"file"` - Nacos NacosConfig `yaml:"nacos" json:"nacos,omitempty" property:"nacos"` -} diff --git a/pkg/config/configurator.go b/pkg/config/configurator.go deleted file mode 100644 index eefcf03e7..000000000 --- a/pkg/config/configurator.go +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -// Configurator is the interface which wraps GetSeataConfig -type Configurator interface { - GetSeataConfig() *SeataConf -} diff --git a/pkg/config/doc.go b/pkg/config/doc.go deleted file mode 100644 index 3cc0a4d22..000000000 --- a/pkg/config/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// package config defines interfaces to be implemented by Config -package config diff --git a/pkg/config/getty_config.go b/pkg/config/getty_config.go deleted file mode 100644 index 3d49feaf3..000000000 --- a/pkg/config/getty_config.go +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "time" -) - -// GettyConfig -// Config holds supported types by the multiconfig package -type GettyConfig struct { - ReconnectInterval int `default:"0" yaml:"reconnect_interval" json:"reconnect_interval,omitempty"` - // getty_session pool - ConnectionNum int `default:"16" yaml:"connection_number" json:"connection_number,omitempty"` - - // heartbeat - HeartbeatPeriod time.Duration `default:"15s" yaml:"heartbeat_period" json:"heartbeat_period,omitempty"` - - // getty_session tcp parameters - GettySessionParam GettySessionParam `required:"true" yaml:"getty_session_param" json:"getty_session_param,omitempty"` -} - -// GetDefaultGettyConfig ... -func GetDefaultGettyConfig() GettyConfig { - return GettyConfig{ - ReconnectInterval: 0, - ConnectionNum: 1, - HeartbeatPeriod: 10 * time.Second, - GettySessionParam: GettySessionParam{ - CompressEncoding: false, - TCPNoDelay: true, - TCPKeepAlive: true, - KeepAlivePeriod: 180 * time.Second, - TCPRBufSize: 2144, - TCPWBufSize: 65536, - TCPReadTimeout: time.Second, - TCPWriteTimeout: 5 * time.Second, - WaitTimeout: time.Second, - CronPeriod: time.Second, - MaxMsgLen: 4096, - SessionName: "rpc_client", - }, - } -} - -type Shutdown struct { - Wait time.Duration `yaml:"wait" json:"wait,omitempty" property:"wait"` -} - -type Transport struct { - Shutdown Shutdown `yaml:"shutdown" json:"shutdown,omitempty" property:"shutdown"` - Type string `yaml:"type" json:"type,omitempty" property:"type"` - Server string `yaml:"server" json:"server,omitempty" property:"server"` - Heartbeat bool `yaml:"heartbeat" json:"heartbeat,omitempty" property:"heartbeat"` - Serialization string `yaml:"serialization" json:"serialization,omitempty" property:"serialization"` - Compressor string `yaml:"compressor" json:"compressor,omitempty" property:"compressor"` - EnableTmClientBatchSendRequest bool `yaml:"enable-tm-client-batch-send-request" json:"enable-tm-client-batch-send-request,omitempty" property:"enable-tm-client-batch-send-request"` - EnableRmClientBatchSendRequest bool `yaml:"enable-rm-client-batch-send-request" json:"enable-rm-client-batch-send-request,omitempty" property:"enable-rm-client-batch-send-request"` - RPCRmRequestTimeout time.Duration `yaml:"rpc-rm-request-timeout" json:"rpc-rm-request-timeout,omitempty" property:"rpc-rm-request-timeout"` - RPCTmRequestTimeout time.Duration `yaml:"rpc-tm-request-timeout" json:"rpc-tm-request-timeout,omitempty" property:"rpc-tm-request-timeout"` -} - -type GettySessionParam struct { - CompressEncoding bool `yaml:"compress-encoding" json:"compress-encoding,omitempty" property:"compress-encoding"` - TCPNoDelay bool `yaml:"tcp-no-delay" json:"tcp-no-delay,omitempty" property:"tcp-no-delay"` - TCPKeepAlive bool `yaml:"tcp-keep-alive" json:"tcp-keep-alive,omitempty" property:"tcp-keep-alive"` - KeepAlivePeriod time.Duration `yaml:"keep-alive-period" json:"keep-alive-period,omitempty" property:"keep-alive-period"` - TCPRBufSize int `yaml:"tcp-r-buf-size" json:"tcp-r-buf-size,omitempty" property:"tcp-r-buf-size"` - TCPWBufSize int `yaml:"tcp-w-buf-size" json:"tcp-w-buf-size,omitempty" property:"tcp-w-buf-size"` - TCPReadTimeout time.Duration `yaml:"tcp-read-timeout" json:"tcp-read-timeout,omitempty" property:"tcp-read-timeout"` - TCPWriteTimeout time.Duration `yaml:"tcp-write-timeout" json:"tcp-write-timeout,omitempty" property:"tcp-write-timeout"` - WaitTimeout time.Duration `yaml:"wait-timeout" json:"wait-timeout,omitempty" property:"wait-timeout"` - MaxMsgLen int `yaml:"max-msg-len" json:"max-msg-len,omitempty" property:"max-msg-len"` - SessionName string `yaml:"session-name" json:"session-name,omitempty" property:"session-name"` - CronPeriod time.Duration `default:"1" yaml:"cron_period" json:"cron_period,omitempty"` -} diff --git a/pkg/config/log_config.go b/pkg/config/log_config.go deleted file mode 100644 index 69d899a6e..000000000 --- a/pkg/config/log_config.go +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -type LogConf struct { - ExceptionRate int `yaml:"exception-rate" json:"exception-rate,omitempty" property:"exception-rate"` -} diff --git a/pkg/config/parser/configuration_parser.go b/pkg/config/parser/configuration_parser.go deleted file mode 100644 index 9177d8e32..000000000 --- a/pkg/config/parser/configuration_parser.go +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package parser - -import ( - "io/ioutil" - "path" - - "github.com/pkg/errors" - "gopkg.in/yaml.v2" -) - -// ConfigurationParser interface -type ConfigurationParser interface { - Parse(string) (map[string]string, error) -} - -// LoadYMLConfig Load yml config byte from file check file type is *.yml or *.yaml` -func LoadYMLConfig(confProFile string) ([]byte, error) { - if len(confProFile) == 0 { - return nil, errors.Errorf("application configure(provider) file name is nil") - } - - if path.Ext(confProFile) != ".yml" && path.Ext(confProFile) != ".yaml" { - return nil, errors.Errorf("application configure file name{%v} suffix must be .yml or .yaml", confProFile) - } - - return ioutil.ReadFile(confProFile) -} - -// UnmarshalYML unmarshals decodes the first document found within the in byte slice and assigns decoded values into the out value. -func UnmarshalYML(data []byte, out interface{}) error { - return yaml.Unmarshal(data, out) -} diff --git a/pkg/config/parser/configuration_parser_test.go b/pkg/config/parser/configuration_parser_test.go deleted file mode 100644 index a22013221..000000000 --- a/pkg/config/parser/configuration_parser_test.go +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package parser - -import ( - "path/filepath" - "testing" - - "github.com/seata/seata-go/pkg/util/log" - "github.com/stretchr/testify/assert" -) - -func TestLoadYMLConfig(t *testing.T) { - conPath, err := filepath.Abs("../../../conf/seata_config.yml") - if err != nil { - log.Infof(err.Error()) - } - confBytes, err := LoadYMLConfig(conPath) - if err != nil { - log.Infof(err.Error()) - } - assert.NotEmpty(t, confBytes) -} diff --git a/pkg/config/registry_config.go b/pkg/config/registry_config.go deleted file mode 100644 index 4e548177b..000000000 --- a/pkg/config/registry_config.go +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -type File struct { - Name string `yaml:"name" json:"name,omitempty" property:"name"` -} - -type NacosRegistry struct { - Application string `yaml:"application" json:"application,omitempty" property:"application"` - ServerAddr string `yaml:"server-addr" json:"server-addr,omitempty" property:"server-addr"` - Group string `yaml:"group" json:"group,omitempty" property:"group"` - Namespace string `yaml:"namespace" json:"namespace,omitempty" property:"namespace"` - Username string `yaml:"username" json:"username,omitempty" property:"username"` - Password string `yaml:"password" json:"password,omitempty" property:"password"` -} - -// Registry is Registration Center configuration file -type Registry struct { - Type string `yaml:"type" json:"type,omitempty" property:"type"` - File File `yaml:"file" json:"file,omitempty" property:"file"` - Nacos NacosRegistry `yaml:"nacos" json:"nacos,omitempty" property:"nacos"` -} diff --git a/pkg/config/seata_config.go b/pkg/config/seata_config.go deleted file mode 100644 index a1edc3a40..000000000 --- a/pkg/config/seata_config.go +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "path/filepath" - - "github.com/seata/seata-go/pkg/config/parser" - "github.com/seata/seata-go/pkg/util/log" -) - -var ( - DefaultSeataConf SeataConf -) - -// SeataConf is seata config object -type SeataConf struct { - Seata Seata `default:"" yaml:"" json:"seata"` -} - -// Init seata configurator -func Init() error { - configPath, err := filepath.Abs("../../conf/seata_config.yml") - if err != nil { - log.Errorf("Init seata config error [get config file path error]: {%#v}", err.Error()) - return err - } - configByte, err := parser.LoadYMLConfig(configPath) - if err != nil { - log.Errorf("Init seata config error [load yml file error]: {%#v}", err.Error()) - return err - } - err = parser.UnmarshalYML(configByte, &DefaultSeataConf) - if err != nil { - log.Errorf("Init seata config error [unmarshal yml to seataconf error]:{%#v}", err.Error()) - return err - } - return nil -} - -type Seata struct { - Enabled bool `yaml:"enabled" json:"enabled,omitempty" property:"enabled"` - ApplicationID string `yaml:"application-id" json:"application-id,omitempty" property:"application-id"` - TxServiceGroup string `yaml:"tx-service-group" json:"tx-service-group,omitempty" property:"tx-service-group"` - AccessKey string `yaml:"access-key" json:"access-key,omitempty" property:"access-key"` - SecretKey string `yaml:"secret-key" json:"secret-key,omitempty" property:"secret-key"` - EnableAutoDataSourceProxy bool `yaml:"enable-auto-data-source-proxy" json:"enable-auto-data-source-proxy,omitempty" property:"enable-auto-data-source-proxy"` - DataSourceProxyMode string `yaml:"data-source-proxy-mode" json:"data-source-proxy-mode,omitempty" property:"data-source-proxy-mode"` - ClientConf ClientConf `yaml:"client" json:"client,omitempty" property:"client"` - Service Service `yaml:"service" json:"service,omitempty" property:"service"` - Transport Transport `yaml:"transport" json:"transport,omitempty" property:"transport"` - Config Config `yaml:"config" json:"config,omitempty" property:"config"` - Registry Registry `yaml:"registry" json:"registry,omitempty" property:"registry"` - LogConf LogConf `yaml:"log" json:"log,omitempty" property:"log"` - TccConf TccConf `yaml:"tcc" json:"tcc,omitempty" property:"tcc"` - GettySessionParam GettySessionParam `yaml:"getty-session-param" json:"getty-session-param,omitempty" property:"getty-session-param"` -} diff --git a/pkg/config/seata_config_test.go b/pkg/config/seata_config_test.go deleted file mode 100644 index 547f8233b..000000000 --- a/pkg/config/seata_config_test.go +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import ( - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -func TestInit(t *testing.T) { - Init() - assert.Equal(t, DefaultSeataConf.Seata.Enabled, true) - assert.Equal(t, DefaultSeataConf.Seata.ApplicationID, "applicationName") - assert.Equal(t, DefaultSeataConf.Seata.TxServiceGroup, "default_tx_group") - assert.Equal(t, DefaultSeataConf.Seata.AccessKey, "aliyunAccessKey") - assert.Equal(t, DefaultSeataConf.Seata.SecretKey, "aliyunSecretKey") - assert.Equal(t, DefaultSeataConf.Seata.EnableAutoDataSourceProxy, true) - assert.Equal(t, DefaultSeataConf.Seata.DataSourceProxyMode, "AT") - - // client - // rm - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.AsyncCommitBufferLimit, 10000) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.ReportRetryCount, 5) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.TableMetaCheckEnable, false) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.ReportSuccessEnable, false) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.SagaBranchRegisterEnable, false) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.SagaJSONParser, "fastjson") - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.SagaRetryPersistModeUpdate, false) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.SagaCompensatePersistModeUpdate, false) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.TccActionInterceptorOrder, -2147482648) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.SQLParserType, "druid") - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.Lock.RetryInterval, 10) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.Lock.RetryTimes, time.Duration(30_000_000_000)) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Rmconf.Lock.RetryPolicyBranchRollbackOnConflict, true) - // tm - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Tmconf.CommitRetryCount, 5) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Tmconf.RollbackRetryCount, 5) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Tmconf.DefaultGlobalTransactionTimeout, time.Duration(10_000_000_000)) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Tmconf.DegradeCheck, false) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Tmconf.DegradeCheckPeriod, 2000) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Tmconf.DegradeCheckAllowTimes, time.Duration(10_000_000_000)) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Tmconf.InterceptorOrder, -2147482648) - // undo - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Undo.DataValidation, true) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Undo.LogSerialization, "jackson") - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Undo.LogTable, "undo_log") - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Undo.OnlyCareUpdateColumns, true) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Undo.Compress.Enable, true) - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Undo.Compress.Type, "zip") - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.Undo.Compress.Threshold, 64) - // load-balance - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.LoadBalance.Type, "RandomLoadBalance") - assert.Equal(t, DefaultSeataConf.Seata.ClientConf.LoadBalance.VirtualNodes, 10) - - // service - assert.Equal(t, DefaultSeataConf.Seata.Service.VgroupMapping.DefaultTxGroup, "default") - assert.Equal(t, DefaultSeataConf.Seata.Service.Grouplist.Default, "127.0.0.1:8091") - assert.Equal(t, DefaultSeataConf.Seata.Service.EnableDegrade, false) - assert.Equal(t, DefaultSeataConf.Seata.Service.DisableGlobalTransaction, false) - - // transport - assert.Equal(t, DefaultSeataConf.Seata.Transport.Shutdown.Wait, time.Duration(3_000_000_000)) - assert.Equal(t, DefaultSeataConf.Seata.Transport.Type, "TCP") - assert.Equal(t, DefaultSeataConf.Seata.Transport.Server, "NIO") - assert.Equal(t, DefaultSeataConf.Seata.Transport.Heartbeat, true) - assert.Equal(t, DefaultSeataConf.Seata.Transport.Serialization, "seata") - assert.Equal(t, DefaultSeataConf.Seata.Transport.Compressor, "none") - assert.Equal(t, DefaultSeataConf.Seata.Transport.EnableTmClientBatchSendRequest, false) - assert.Equal(t, DefaultSeataConf.Seata.Transport.EnableRmClientBatchSendRequest, true) - assert.Equal(t, DefaultSeataConf.Seata.Transport.RPCRmRequestTimeout, time.Duration(30_000_000_000)) - assert.Equal(t, DefaultSeataConf.Seata.Transport.RPCTmRequestTimeout, time.Duration(30_000_000_000)) - - // config - assert.Equal(t, DefaultSeataConf.Seata.Config.Type, "file") - assert.Equal(t, DefaultSeataConf.Seata.Config.File.Name, "config.conf") - assert.Equal(t, DefaultSeataConf.Seata.Config.Nacos.Namespace, "") - assert.Equal(t, DefaultSeataConf.Seata.Config.Nacos.ServerAddr, "127.0.0.1:8848") - assert.Equal(t, DefaultSeataConf.Seata.Config.Nacos.Group, "SEATA_GROUP") - assert.Equal(t, DefaultSeataConf.Seata.Config.Nacos.Username, "") - assert.Equal(t, DefaultSeataConf.Seata.Config.Nacos.Password, "") - assert.Equal(t, DefaultSeataConf.Seata.Config.Nacos.DataID, "seata.properties") - - // registry - assert.Equal(t, DefaultSeataConf.Seata.Registry.Type, "file") - assert.Equal(t, DefaultSeataConf.Seata.Registry.File.Name, "registry.conf") - assert.Equal(t, DefaultSeataConf.Seata.Registry.Nacos.Application, "seata-server") - assert.Equal(t, DefaultSeataConf.Seata.Registry.Nacos.ServerAddr, "127.0.0.1:8848") - assert.Equal(t, DefaultSeataConf.Seata.Registry.Nacos.Group, "SEATA_GROUP") - assert.Equal(t, DefaultSeataConf.Seata.Registry.Nacos.Namespace, "") - assert.Equal(t, DefaultSeataConf.Seata.Registry.Nacos.Username, "") - assert.Equal(t, DefaultSeataConf.Seata.Registry.Nacos.Password, "") - - // log - assert.Equal(t, DefaultSeataConf.Seata.LogConf.ExceptionRate, 100) - - // tcc - assert.Equal(t, DefaultSeataConf.Seata.TccConf.Fence.LogTableName, "tcc_fence_log") - assert.Equal(t, DefaultSeataConf.Seata.TccConf.Fence.CleanPeriod, time.Duration(60_000_000_000)) - - // getty-session-param - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.CompressEncoding, false) - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.TCPNoDelay, true) - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.TCPKeepAlive, true) - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.KeepAlivePeriod, time.Duration(120_000_000_000)) - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.TCPRBufSize, 262144) - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.TCPWBufSize, 65536) - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.TCPReadTimeout, time.Duration(1_000_000_000)) - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.TCPWriteTimeout, time.Duration(5_000_000_000)) - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.WaitTimeout, time.Duration(1_000_000_000)) - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.MaxMsgLen, 16498688) - assert.Equal(t, DefaultSeataConf.Seata.GettySessionParam.SessionName, "client") -} diff --git a/pkg/config/service_config.go b/pkg/config/service_config.go deleted file mode 100644 index 21fb7d588..000000000 --- a/pkg/config/service_config.go +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -type Grouplist struct { - Default string `yaml:"default" json:"default,omitempty" property:"default"` -} - -type VgroupMapping struct { - DefaultTxGroup string `yaml:"default_tx_group" json:"default_tx_group,omitempty" property:"default_tx_group"` -} - -type Service struct { - VgroupMapping VgroupMapping `yaml:"vgroup-mapping" json:"vgroup-mapping,omitempty" property:"vgroup-mapping"` - Grouplist Grouplist `yaml:"grouplist" json:"grouplist,omitempty" property:"grouplist"` - EnableDegrade bool `yaml:"enable-degrade" json:"enable-degrade,omitempty" property:"enable-degrade"` - DisableGlobalTransaction bool `yaml:"disable-global-transaction" json:"disable-global-transaction,omitempty" property:"disable-global-transaction"` -} diff --git a/pkg/config/tcc_config.go b/pkg/config/tcc_config.go deleted file mode 100644 index 97c30c137..000000000 --- a/pkg/config/tcc_config.go +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package config - -import "time" - -type Fence struct { - LogTableName string `yaml:"log-table-name" json:"log-table-name,omitempty" property:"log-table-name"` - CleanPeriod time.Duration `yaml:"clean-period" json:"clean-period,omitempty" property:"clean-period"` -} - -type TccConf struct { - Fence Fence `yaml:"fence" json:"fence,omitempty" property:"fence"` -}