-
Notifications
You must be signed in to change notification settings - Fork 0
/
noop.go
61 lines (46 loc) · 1.34 KB
/
noop.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2020 PingCAP, Inc. Licensed under Apache-2.0.
package storage
import (
"context"
)
type noopStorage struct{}
// Write file to storage.
func (*noopStorage) Write(ctx context.Context, name string, data []byte) error {
return nil
}
// Read storage file.
func (*noopStorage) Read(ctx context.Context, name string) ([]byte, error) {
return []byte{}, nil
}
// FileExists return true if file exists.
func (*noopStorage) FileExists(ctx context.Context, name string) (bool, error) {
return false, nil
}
// Open a Reader by file path.
func (*noopStorage) Open(ctx context.Context, path string) (ReadSeekCloser, error) {
return noopReader{}, nil
}
// WalkDir traverse all the files in a dir.
func (*noopStorage) WalkDir(ctx context.Context, opt *WalkOption, fn func(string, int64) error) error {
return nil
}
func (s *noopStorage) URI() string {
return "noop:///"
}
// CreateUploader implenments ExternalStorage interface.
func (*noopStorage) CreateUploader(ctx context.Context, name string) (Uploader, error) {
panic("noop storage not support multi-upload")
}
func newNoopStorage() *noopStorage {
return &noopStorage{}
}
type noopReader struct{}
func (noopReader) Read(p []byte) (n int, err error) {
return 0, nil
}
func (noopReader) Close() error {
return nil
}
func (noopReader) Seek(offset int64, whence int) (int64, error) {
return 0, nil
}