Skip to content

Commit

Permalink
fix typos and go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Акулов Александр Яковлевич committed Jan 28, 2019
1 parent 6a48ab1 commit 5d4f887
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
8 changes: 4 additions & 4 deletions clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ func (ch *ClickHouse) CopyData(table BackupTable) error {
return nil
}

func convertPartition(deatachedTableFoler string, depricatedCreation bool) string {
func convertPartition(deatachedTableFoler string, deprecatedCreation bool) string {
// TODO: rewrite this magic
begin := strings.Split(deatachedTableFoler, "_")[0]
if begin == "all" {
// ENGINE = MergeTree ORDER BY id
return "tuple()"
}
if depricatedCreation {
if deprecatedCreation {
// Deprecated Method for Creating a Table
// ENGINE = MergeTree(Date, (TimeStamp, Log), 8192)
return begin[:6]
Expand All @@ -273,9 +273,9 @@ func convertPartition(deatachedTableFoler string, depricatedCreation bool) strin
}

// AttachPatritions - execute ATTACH command for specific table
func (ch *ClickHouse) AttachPatritions(table BackupTable, depricatedCreation bool) error {
func (ch *ClickHouse) AttachPatritions(table BackupTable, deprecatedCreation bool) error {
// TODO: need tests
partitionName := convertPartition(table.Partitions[0].Name, depricatedCreation)
partitionName := convertPartition(table.Partitions[0].Name, deprecatedCreation)
if ch.DryRun {
log.Printf("ATTACH partition '%s' for %s.%s increment %d ...skip dry-run", partitionName, table.Database, table.Name, table.Increment)
return nil
Expand Down
16 changes: 9 additions & 7 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ func LoadConfig(configLocation string) (*Config, error) {
return config, validateConfig(config)
}

func validateConfig (config *Config) error {
func validateConfig(config *Config) error {
switch config.S3.OverwriteStrategy {
case
case
"skip",
"etag",
"always": break
default: return fmt.Errorf("unknown s3.overwrite_strategy it can be 'skip', 'etag', 'always'")
"always":
break
default:
return fmt.Errorf("unknown s3.overwrite_strategy it can be 'skip', 'etag', 'always'")
}
return nil
}
Expand All @@ -82,9 +84,9 @@ func defaultConfig() *Config {
Port: 9000,
},
S3: S3Config{
Region: "us-east-1",
DisableSSL: false,
ACL: "private",
Region: "us-east-1",
DisableSSL: false,
ACL: "private",
OverwriteStrategy: "always",
},
}
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ func main() {
Hidden: false,
},
cli.BoolFlag{
Name: "depricated, d",
Name: "deprecated, d",
Hidden: false,
Usage: "Set this flag if Table was created of deprecated method: ENGINE = MergeTree(Date, (TimeStamp, Log), 8192)",
Usage: "Set this flag if Table was created of deprecated method: ENGINE = MergeTree(Date, (TimeStamp, Log), 8192)",
},
),
},
Expand Down Expand Up @@ -211,7 +211,7 @@ func freeze(config Config, args []string, dryRun bool) error {
return nil
}

func restore(config Config, args []string, dryRun bool, increments []int, depricatedCreation bool) error {
func restore(config Config, args []string, dryRun bool, increments []int, deprecatedCreation bool) error {
ch := &ClickHouse{
DryRun: dryRun,
Config: &config.ClickHouse,
Expand All @@ -236,7 +236,7 @@ func restore(config Config, args []string, dryRun bool, increments []int, depric
if err := ch.CopyData(table); err != nil {
return fmt.Errorf("can't restore %s.%s increment %d with %v", table.Database, table.Name, table.Increment, err)
}
if err := ch.AttachPatritions(table, depricatedCreation); err != nil {
if err := ch.AttachPatritions(table, deprecatedCreation); err != nil {
return fmt.Errorf("can't attach partitions for table %s.%s with %v", table.Database, table.Name, err)
}
}
Expand Down
1 change: 1 addition & 0 deletions s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func (s *S3) newSyncFolderIterator(localPath, dstPath string) (*SyncFolderIterat
if existFile.size == info.Size() {
switch s.Config.OverwriteStrategy {
case "skip":
skipFilesCount++
return nil
case "etag":
if existFile.etag == GetEtag(filePath) {
Expand Down

0 comments on commit 5d4f887

Please sign in to comment.