Documentation ¶
Overview ¶
Package drivers abstracts different object storages, such as local, s3
Index ¶
- Constants
- Variables
- func FailSaveEnabled() bool
- func GetSegmentData(ctx context.Context, uri string) ([]byte, error)
- func PrepareOSURL(input string) (string, error)
- func Save2GS(fileName string, data []byte) (string, error)
- func SaveFile2GS(inpFileName, targetFileName string) (string, error)
- func SavePairData2GS(trusturi string, data1 []byte, untrusturi string, data2 []byte, suffix string, ...) error
- func SaveRetried(ctx context.Context, sess OSSession, name string, data []byte, ...) (string, error)
- func SetCreds(bucket, creds string)
- type FileInfo
- type FileInfoReader
- type MemoryOS
- type MemorySession
- func (ostore *MemorySession) EndSession()
- func (ostore *MemorySession) GetData(name string) []byte
- func (ostore *MemorySession) GetInfo() *net.OSInfo
- func (ostore *MemorySession) IsExternal() bool
- func (ostore *MemorySession) IsOwn(url string) bool
- func (ostore *MemorySession) ListFiles(ctx context.Context, prefix, delim string) (PageInfo, error)
- func (ostore *MemorySession) OS() OSDriver
- func (ostore *MemorySession) ReadData(ctx context.Context, name string) (*FileInfoReader, error)
- func (ostore *MemorySession) SaveData(ctx context.Context, name string, data io.Reader, meta map[string]string, ...) (string, error)
- type MockOSSession
- func (s *MockOSSession) EndSession()
- func (s *MockOSSession) GetInfo() *net.OSInfo
- func (s *MockOSSession) IsExternal() bool
- func (s *MockOSSession) IsOwn(url string) bool
- func (s *MockOSSession) ListFiles(ctx context.Context, prefix, delim string) (PageInfo, error)
- func (s *MockOSSession) OS() OSDriver
- func (s *MockOSSession) ReadData(ctx context.Context, name string) (*FileInfoReader, error)
- func (s *MockOSSession) SaveData(ctx context.Context, name string, data io.Reader, meta map[string]string, ...) (string, error)
- type OSDriver
- func NewCustomS3Driver(host, bucket, region, accessKey, accessKeySecret string, useFullAPI bool) (OSDriver, error)
- func NewGoogleDriver(bucket, keyData string, useFullAPI bool) (OSDriver, error)
- func NewS3Driver(region, bucket, accessKey, accessKeySecret string, useFullAPI bool) (OSDriver, error)
- func ParseOSURL(input string, useFullAPI bool) (OSDriver, error)
- type OSSession
- type OverwriteQueue
- type PageInfo
Constants ¶
const (
// S3_POLICY_EXPIRE_IN_HOURS how long access rights given to other node will be valid
S3_POLICY_EXPIRE_IN_HOURS = 24
)
Variables ¶
var ErrNoNextPage = fmt.Errorf("no next page")
ErrNoNextPage indicates that there is no next page in ListFiles
var FailSaveBucketName string
FailSaveBucketName name of the bucket to save FV faild segments to
var TestMemoryStorages map[string]*MemoryOS
TestMemoryStorages used for testing purposes
var Testing bool
Testing indicates that test is running
Functions ¶
func PrepareOSURL ¶ added in v0.5.13
PrepareOSURL used for resolving files when necessary and turning into a URL. Don't use this when the URL comes from untrusted sources e.g. AuthWebhookUrl.
func SaveFile2GS ¶ added in v0.5.33
SaveFile2GS saves file to Google Cloud Storage
func SavePairData2GS ¶ added in v0.5.33
Types ¶
type FileInfoReader ¶ added in v0.5.13
type FileInfoReader struct { FileInfo Metadata map[string]string Body io.ReadCloser }
func ParallelReadFiles ¶ added in v0.5.13
func ParallelReadFiles(ctx context.Context, sess OSSession, filesNames []string, workers int) ([]*FileInfoReader, [][]byte, error)
ParallelReadFiles reads files in parallel, using specified number of jobs
type MemoryOS ¶
type MemoryOS struct {
// contains filtered or unexported fields
}
func NewMemoryDriver ¶
func (*MemoryOS) GetSession ¶
func (ostore *MemoryOS) GetSession(path string) *MemorySession
func (*MemoryOS) NewSession ¶
type MemorySession ¶
type MemorySession struct {
// contains filtered or unexported fields
}
func (*MemorySession) EndSession ¶
func (ostore *MemorySession) EndSession()
EndSession clears memory cache
func (*MemorySession) GetData ¶
func (ostore *MemorySession) GetData(name string) []byte
GetData returns the cached data for a name.
A name can be an absolute or relative URI. An absolute URI has the following format: - ostore.os.baseURI + /stream/ + ostore.path + path + file The following are valid relative URIs: - /stream/ + ostore.path + path + file (if ostore.os.baseURI is empty) - ostore.path + path + file
func (*MemorySession) GetInfo ¶
func (ostore *MemorySession) GetInfo() *net.OSInfo
func (*MemorySession) IsExternal ¶
func (ostore *MemorySession) IsExternal() bool
func (*MemorySession) IsOwn ¶ added in v0.5.13
func (ostore *MemorySession) IsOwn(url string) bool
func (*MemorySession) OS ¶ added in v0.5.13
func (ostore *MemorySession) OS() OSDriver
func (*MemorySession) ReadData ¶ added in v0.5.13
func (ostore *MemorySession) ReadData(ctx context.Context, name string) (*FileInfoReader, error)
type MockOSSession ¶ added in v0.5.13
func NewMockOSSession ¶ added in v0.5.19
func NewMockOSSession() *MockOSSession
func (*MockOSSession) EndSession ¶ added in v0.5.13
func (s *MockOSSession) EndSession()
func (*MockOSSession) GetInfo ¶ added in v0.5.13
func (s *MockOSSession) GetInfo() *net.OSInfo
func (*MockOSSession) IsExternal ¶ added in v0.5.13
func (s *MockOSSession) IsExternal() bool
func (*MockOSSession) IsOwn ¶ added in v0.5.13
func (s *MockOSSession) IsOwn(url string) bool
func (*MockOSSession) OS ¶ added in v0.5.13
func (s *MockOSSession) OS() OSDriver
func (*MockOSSession) ReadData ¶ added in v0.5.13
func (s *MockOSSession) ReadData(ctx context.Context, name string) (*FileInfoReader, error)
type OSDriver ¶
OSDriver common interface for Object Storage
var NodeStorage OSDriver
NodeStorage is current node's primary driver
var RecordStorage OSDriver
RecordStorage is current node's "stream recording" driver
func NewCustomS3Driver ¶ added in v0.5.13
func NewCustomS3Driver(host, bucket, region, accessKey, accessKeySecret string, useFullAPI bool) (OSDriver, error)
NewCustomS3Driver for creating S3-compatible stores other than S3 itself
func NewGoogleDriver ¶
func NewS3Driver ¶
type OSSession ¶
type OSSession interface { OS() OSDriver SaveData(ctx context.Context, name string, data io.Reader, meta map[string]string, timeout time.Duration) (string, error) EndSession() // Info in order to have this session used via RPC GetInfo() *net.OSInfo // Indicates whether data may be external to this node IsExternal() bool // Indicates whether this is the correct OS for a given URL IsOwn(url string) bool // ListFiles return list of files ListFiles(ctx context.Context, prefix, delim string) (PageInfo, error) ReadData(ctx context.Context, name string) (*FileInfoReader, error) }
func NewSession ¶
NewSession returns new session based on OSInfo received from the network
type OverwriteQueue ¶ added in v0.5.19
type OverwriteQueue struct {
// contains filtered or unexported fields
}
func NewOverwriteQueue ¶ added in v0.5.19
func (*OverwriteQueue) Save ¶ added in v0.5.19
func (oq *OverwriteQueue) Save(data []byte)
Save queues data to be saved
func (*OverwriteQueue) StopAfter ¶ added in v0.5.19
func (oq *OverwriteQueue) StopAfter(pause time.Duration)
StopAfter stops reading loop after some time