| 149 | } |
| 150 | |
| 151 | func (s *Spec) SetDefaults() { |
| 152 | if !strings.Contains(s.Path, varTable) { |
| 153 | // for backwards-compatibility, default to given path plus /{{TABLE}}.[format].{{UUID}} if |
| 154 | // no {{TABLE}} value is found in the path string |
| 155 | s.Path += fmt.Sprintf("/%s.%s", varTable, s.Format) |
| 156 | if !s.NoRotate { |
| 157 | s.Path += "." + varUUID |
| 158 | } |
| 159 | } |
| 160 | if s.TestWrite == nil { |
| 161 | b := true |
| 162 | s.TestWrite = &b |
| 163 | } |
| 164 | if s.BatchSize == nil { |
| 165 | if s.NoRotate { |
| 166 | s.BatchSize = ptr(int64(0)) |
| 167 | } else { |
| 168 | s.BatchSize = ptr(int64(10000)) |
| 169 | } |
| 170 | } |
| 171 | if s.BatchSizeBytes == nil { |
| 172 | if s.NoRotate { |
| 173 | s.BatchSizeBytes = ptr(int64(0)) |
| 174 | } else { |
| 175 | s.BatchSizeBytes = ptr(int64(50 * 1024 * 1024)) // 50 MiB |
| 176 | } |
| 177 | } |
| 178 | if s.BatchTimeout == nil { |
| 179 | if s.NoRotate { |
| 180 | d := configtype.NewDuration(0) |
| 181 | s.BatchTimeout = &d |
| 182 | } else { |
| 183 | d := configtype.NewDuration(30 * time.Second) |
| 184 | s.BatchTimeout = &d |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | if s.LocalProfile != "" { |
| 189 | s.Credentials = &Credentials{ |
| 190 | LocalProfile: s.LocalProfile, |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | if s.MaxRetries == nil { |
| 195 | maxRetries := 3 |
| 196 | s.MaxRetries = &maxRetries |
| 197 | } |
| 198 | |
| 199 | if s.MaxBackoff == nil { |
| 200 | maxBackoff := 30 |
| 201 | s.MaxBackoff = &maxBackoff |
| 202 | } |
| 203 | if s.PartSize == nil { |
| 204 | maxPartSize := manager.DefaultUploadPartSize |
| 205 | s.PartSize = &maxPartSize |
| 206 | } |
| 207 | } |
| 208 | |