...

Source file src/code.rocketnine.space/tslocum/gophast/pkg/config/config.go

Documentation: code.rocketnine.space/tslocum/gophast/pkg/config

     1  package config
     2  
     3  import (
     4  	"sync"
     5  	"time"
     6  )
     7  
     8  const (
     9  	DefaultMinSplitSize          = 10 * 1024 * 1024
    10  	DefaultMinSplitSizeFormatted = "10 MiB"
    11  	DefaultConnectTimeout        = 1 * time.Minute
    12  	DefaultTransferTimeout       = 20 * time.Second
    13  	DefaultMaxConnections        = 2
    14  	DefaultAutoSaveControl       = 15 * time.Second
    15  	DefaultRetryDelay            = 2 * time.Second
    16  	DefaultMaxRetries            = 0
    17  )
    18  
    19  type LogLevel int
    20  
    21  const (
    22  	LogNone LogLevel = iota
    23  	LogStandard
    24  	LogVerbose
    25  )
    26  
    27  type ProgressLevel int
    28  
    29  const (
    30  	ProgressNone ProgressLevel = iota
    31  	ProgressStatic
    32  	ProgressDynamic
    33  )
    34  
    35  type Config struct {
    36  	MaxLogLevel LogLevel
    37  	Debug       bool
    38  
    39  	ProgressLevel ProgressLevel
    40  	TaskWidth     int
    41  	TaskFormat    string
    42  
    43  	Force       bool
    44  	Preallocate bool
    45  
    46  	ConnectTimeout  time.Duration
    47  	TransferTimeout time.Duration
    48  
    49  	Resume          bool
    50  	AutoSaveControl time.Duration
    51  
    52  	RetryDelay time.Duration
    53  	MaxRetries int
    54  
    55  	DownloadDir  string
    56  	DownloadName string
    57  
    58  	MinSplitSize   int64
    59  	MaxConnections int64
    60  
    61  	UserAgent      string
    62  	UserAgentExtra string
    63  }
    64  
    65  func (c *Config) SetUserAgent() {
    66  	var ua string
    67  	if c.UserAgentExtra != "" {
    68  		ua = c.UserAgentExtra + " "
    69  	}
    70  	ua += "gophast"
    71  	if Version != "" {
    72  		ua += "/" + Version
    73  	}
    74  	ua += " (https://gitlab.com/tslocum/gophast)"
    75  
    76  	c.UserAgent = ua
    77  }
    78  
    79  var Version string
    80  
    81  var C = &Config{
    82  	MaxLogLevel:   LogNone,
    83  	ProgressLevel: ProgressNone,
    84  
    85  	Force:       false,
    86  	Preallocate: true,
    87  
    88  	ConnectTimeout:  DefaultConnectTimeout,
    89  	TransferTimeout: DefaultTransferTimeout,
    90  
    91  	Resume:          true,
    92  	AutoSaveControl: DefaultAutoSaveControl,
    93  
    94  	RetryDelay: DefaultRetryDelay,
    95  	MaxRetries: DefaultMaxRetries,
    96  
    97  	DownloadDir:  "./",
    98  	DownloadName: "",
    99  
   100  	MinSplitSize:   DefaultMinSplitSize,
   101  	MaxConnections: DefaultMaxConnections,
   102  }
   103  
   104  var WG = &sync.WaitGroup{}
   105  

View as plain text