You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

getty_config.go 3.4 kB

3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package config
  18. import (
  19. "time"
  20. )
  21. // GettyConfig
  22. //Config holds supported types by the multiconfig package
  23. type GettyConfig struct {
  24. ReconnectInterval int `default:"0" yaml:"reconnect_interval" json:"reconnect_interval,omitempty"`
  25. // getty_session pool
  26. ConnectionNum int `default:"16" yaml:"connection_number" json:"connection_number,omitempty"`
  27. // heartbeat
  28. HeartbeatPeriod time.Duration `default:"15s" yaml:"heartbeat_period" json:"heartbeat_period,omitempty"`
  29. // getty_session tcp parameters
  30. GettySessionParam GettySessionParam `required:"true" yaml:"getty_session_param" json:"getty_session_param,omitempty"`
  31. }
  32. // GetDefaultGettyConfig ...
  33. func GetDefaultGettyConfig() GettyConfig {
  34. return GettyConfig{
  35. ReconnectInterval: 0,
  36. ConnectionNum: 2,
  37. HeartbeatPeriod: 10 * time.Second,
  38. GettySessionParam: GettySessionParam{
  39. CompressEncoding: false,
  40. TCPNoDelay: true,
  41. TCPKeepAlive: true,
  42. KeepAlivePeriod: 180 * time.Second,
  43. TCPRBufSize: 2144,
  44. TCPWBufSize: 65536,
  45. TCPReadTimeout: time.Second,
  46. TCPWriteTimeout: 5 * time.Second,
  47. WaitTimeout: time.Second,
  48. CronPeriod: time.Second,
  49. MaxMsgLen: 4096,
  50. SessionName: "rpc_client",
  51. },
  52. }
  53. }
  54. // GettySessionParam getty session param
  55. type GettySessionParam struct {
  56. CompressEncoding bool `default:"false" yaml:"compress_encoding" json:"compress_encoding,omitempty"`
  57. TCPNoDelay bool `default:"true" yaml:"tcp_no_delay" json:"tcp_no_delay,omitempty"`
  58. TCPKeepAlive bool `default:"true" yaml:"tcp_keep_alive" json:"tcp_keep_alive,omitempty"`
  59. KeepAlivePeriod time.Duration `default:"180s" yaml:"keep_alive_period" json:"keep_alive_period,omitempty"`
  60. CronPeriod time.Duration `default:"1s" yaml:"keep_alive_period" json:"keep_alive_period,omitempty"`
  61. TCPRBufSize int `default:"262144" yaml:"tcp_r_buf_size" json:"tcp_r_buf_size,omitempty"`
  62. TCPWBufSize int `default:"65536" yaml:"tcp_w_buf_size" json:"tcp_w_buf_size,omitempty"`
  63. TCPReadTimeout time.Duration `default:"1s" yaml:"tcp_read_timeout" json:"tcp_read_timeout,omitempty"`
  64. TCPWriteTimeout time.Duration `default:"5s" yaml:"tcp_write_timeout" json:"tcp_write_timeout,omitempty"`
  65. WaitTimeout time.Duration `default:"7s" yaml:"wait_timeout" json:"wait_timeout,omitempty"`
  66. MaxMsgLen int `default:"4096" yaml:"max_msg_len" json:"max_msg_len,omitempty"`
  67. SessionName string `default:"rpc" yaml:"session_name" json:"session_name,omitempty"`
  68. }

Go Implementation For Seata