github.com/klaytn/klaytn@v1.12.1/datasync/dbsyncer/config.go (about)

     1  // Copyright 2019 The klaytn Authors
     2  // This file is part of the klaytn library.
     3  //
     4  // The klaytn library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The klaytn library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the klaytn library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package dbsyncer
    18  
    19  import "time"
    20  
    21  const (
    22  	BLOCK_MODE = "block"
    23  	HEAD_MODE  = "head"
    24  )
    25  
    26  //go:generate gencodec -type DBConfig -formats toml -out gen_config.go
    27  type DBConfig struct {
    28  	EnabledDBSyncer bool
    29  	EnabledLogMode  bool
    30  
    31  	// DB Config
    32  	DBHost     string `toml:",omitempty"`
    33  	DBPort     string `toml:",omitempty"`
    34  	DBUser     string `toml:",omitempty"`
    35  	DBPassword string `toml:",omitempty"`
    36  	DBName     string `toml:",omitempty"`
    37  
    38  	MaxIdleConns     int           `toml:",omitempty"`
    39  	MaxOpenConns     int           `toml:",omitempty"`
    40  	ConnMaxLifetime  time.Duration `toml:",omitempty"`
    41  	BlockChannelSize int           `toml:",omitempty"`
    42  
    43  	GenQueryThread int `toml:",omitempty"`
    44  	InsertThread   int `toml:",omitempty"`
    45  
    46  	BulkInsertSize int `toml:",omitempty"`
    47  
    48  	Mode      string `toml:",omitempty"`
    49  	EventMode string `toml:",omitempty"`
    50  
    51  	MaxBlockDiff uint64 `toml:",omitempty"`
    52  }
    53  
    54  func DefaultDBConfig() *DBConfig {
    55  	return &DBConfig{
    56  		EnabledDBSyncer: false,
    57  		EnabledLogMode:  false,
    58  
    59  		DBPort: "3306",
    60  
    61  		MaxIdleConns:     50,
    62  		MaxOpenConns:     30,
    63  		ConnMaxLifetime:  1 * time.Hour,
    64  		BlockChannelSize: 5,
    65  
    66  		GenQueryThread: 100,
    67  		InsertThread:   30,
    68  
    69  		BulkInsertSize: 200,
    70  
    71  		Mode:      "multi",
    72  		EventMode: HEAD_MODE,
    73  
    74  		MaxBlockDiff: 0,
    75  	}
    76  }