(ctx context.Context, name string, sortKeys order.SortKeys, seekStride int, thresh int64)
| 314 | } |
| 315 | |
| 316 | func (r *Root) CreatePool(ctx context.Context, name string, sortKeys order.SortKeys, seekStride int, thresh int64) (*Pool, error) { |
| 317 | if name == "HEAD" { |
| 318 | return nil, fmt.Errorf("pool cannot be named %q", name) |
| 319 | } |
| 320 | if r.pools.LookupByName(ctx, name) != nil { |
| 321 | return nil, fmt.Errorf("%s: %w", name, pools.ErrExists) |
| 322 | } |
| 323 | if thresh == 0 { |
| 324 | thresh = data.DefaultThreshold |
| 325 | } |
| 326 | if len(sortKeys) > 1 { |
| 327 | return nil, errors.New("multiple pool keys not supported") |
| 328 | } |
| 329 | config := pools.NewConfig(name, sortKeys, thresh, seekStride) |
| 330 | if err := CreatePool(ctx, r.engine, r.logger, r.path, config); err != nil { |
| 331 | return nil, err |
| 332 | } |
| 333 | pool, err := r.openPool(ctx, config) |
| 334 | if err != nil { |
| 335 | RemovePool(ctx, r.engine, r.path, config) |
| 336 | return nil, err |
| 337 | } |
| 338 | if err := r.pools.Add(ctx, config); err != nil { |
| 339 | RemovePool(ctx, r.engine, r.path, config) |
| 340 | return nil, err |
| 341 | } |
| 342 | return pool, nil |
| 343 | } |
| 344 | |
| 345 | // RemovePool deletes a pool from the configuration journal and deletes all |
| 346 | // data associated with the pool. |
nothing calls this directly
no test coverage detected