-
Notifications
You must be signed in to change notification settings - Fork 146
/
common.go
42 lines (35 loc) · 1.03 KB
/
common.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Package backend contains implementation of various backend providers.
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
*/
package backend
import (
"context"
"time"
"github.com/NVIDIA/aistore/cmn"
"github.com/NVIDIA/aistore/core"
"github.com/NVIDIA/aistore/fs"
)
type ctx = context.Context // used when omitted for shortness sake
func fmtTime(t time.Time) string { return t.Format(time.RFC3339) }
func calcPageSize(pageSize, maxPageSize uint) uint {
if pageSize == 0 {
return maxPageSize
}
return min(pageSize, maxPageSize)
}
//nolint:deadcode,unused // It is used but in `*_mock.go` files.
func newErrInitBackend(provider string) error { return &cmn.ErrInitBackend{Provider: provider} }
func allocPutParams(res core.GetReaderResult, owt cmn.OWT) *core.PutParams {
params := core.AllocPutParams()
{
params.WorkTag = fs.WorkfileColdget
params.Reader = res.R
params.OWT = owt
params.Cksum = res.ExpCksum
params.Size = res.Size
params.Atime = time.Now()
params.ColdGET = true
}
return params
}