github.com/pluswing/datasync@v1.1.1-0.20240218052257-9077f6fc4ae3/data/config.go (about)

     1  package data
     2  
     3  import "path/filepath"
     4  
     5  type TargetMysqlType struct {
     6  	Host     string `default:"localhost"`
     7  	Port     int    `default:"3306"`
     8  	User     string `default:"root"`
     9  	Password string `default:""`
    10  	Database string
    11  }
    12  
    13  type TargetFileType struct {
    14  	Path string
    15  }
    16  
    17  type TargetType struct {
    18  	Kind   string
    19  	Config interface{}
    20  }
    21  
    22  type StorageGcsType struct {
    23  	Bucket string
    24  	Dir    string
    25  }
    26  
    27  type StorageType struct {
    28  	Kind   string
    29  	Config interface{}
    30  }
    31  
    32  type SettingType struct {
    33  	Targets []TargetType
    34  	Storage StorageType
    35  }
    36  
    37  // ---------------------
    38  type DataSyncType struct {
    39  	Version   string        `json:"version"`
    40  	Histories []VersionType `json:"histories"`
    41  }
    42  
    43  type VersionType struct {
    44  	Id      string `json:"id"`
    45  	Time    int64  `json:"time"`
    46  	Message string `json:"message"`
    47  }
    48  
    49  func (v VersionType) FileName() string {
    50  	return v.Id + ".zip"
    51  }
    52  
    53  func (v VersionType) FileNameWithDir(dir string) string {
    54  	return filepath.Join(dir, v.FileName())
    55  }
    56  
    57  // ---------------------
    58  // target funcs
    59  type TargetMysqlFunc func(config TargetMysqlType)
    60  type TargetFileFunc func(config TargetFileType)
    61  
    62  type TargetFuncTable struct {
    63  	Mysql TargetMysqlFunc
    64  	File  TargetFileFunc
    65  }
    66  
    67  // ---------------------
    68  // storage funcs
    69  type StorageGcsFunc func(config StorageGcsType)
    70  
    71  type StorageFuncTable struct {
    72  	Gcs StorageGcsFunc
    73  }