storageclient

package
v0.1.3-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2016 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package storageclient expose client side API usage for the secure storage service (S3 frontend) this package implements the filemanager DataSaver interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Progress

type Progress struct {
	Total    int
	Progress int
	Errors   int
}

Progress is used to maintain the status of various files update, it report the initial number of files and as soon as upload successfully terminates, the number of uploaded parts.

func (*Progress) Done

func (p *Progress) Done() int

Done part of the ProgressStatus interface returns the number of already processed elements.

func (*Progress) TotalUnits

func (p *Progress) TotalUnits() int

TotalUnits part of the ProgressStatus interface returns the total number of units to be processed.

type RequestStatus

type RequestStatus struct {
	ID string

	Progress
	// contains filtered or unexported fields
}

RequestStatus gloabally request related status infos is used to maintain, protected in a concurrent environment, all resources status and a global progress data (that can be used to report the progress status to the UI).

func NewRequestStatus

func NewRequestStatus(reqID string, count int) *RequestStatus

NewRequestStatus creates a new request status, having as pre-requisite that all the ids are different (should always be the case in 3nigm4 scenario).

func (*RequestStatus) Completed

func (rs *RequestStatus) Completed() bool

Completed returns true if all resources composing a request have been processed or not, this do not means that no error occurred but only that API games are over.

func (*RequestStatus) GetStatus

func (rs *RequestStatus) GetStatus(id string) (*Status, bool)

GetStatus retrieve the status of a specified resource id, return the status struct and a bool reporting the presence of the resource or not (it works as the std golang map primitive).

func (*RequestStatus) SetStatus

func (rs *RequestStatus) SetStatus(id string, done bool, result *ct.OpResult) error

SetStatus set the status for a specified resource id. It sets done flag, and a result cd.OpResult structure.

type Status

type Status struct {
	Done bool
	Err  error
	Data []byte
}

Status the status of the required resource operation is used to asyncronously return the data passed back by the job GET method from APIs.

type StorageClient

type StorageClient struct {
	ErrorChan chan error
	// contains filtered or unexported fields
}

StorageClient is the base structure used to implement the interface methods.

func NewStorageClient

func NewStorageClient(
	address string,
	port int,
	token string,
	workersize, queuesize int) (*StorageClient, error, <-chan error)

NewStorageClient creates a new StorageClient structure and setup all required properties. It'll start the working queue that'll be used to enqueue http API facing jobs. The returned read only chan must be used to check for client errors.

func (*StorageClient) Close

func (s *StorageClient) Close()

Close close the active working queue.

func (*StorageClient) DeleteChunks

func (s *StorageClient) DeleteChunks(filename string, files []string, operationID *fm.ContextID) error

DeleteChunks delete, requiring the API frontend, all resources composing a file (several resources compose a single file).

func (*StorageClient) ProgressStatus

func (s *StorageClient) ProgressStatus(requestID fm.ContextID) (fm.ProgressStatus, error)

ProgressStatus conforms to the DataSaver interface and returns progress metrics about the in progress operation.

func (*StorageClient) RetrieveChunks

func (s *StorageClient) RetrieveChunks(filename string, files []string, operationID *fm.ContextID) ([][]byte, error)

RetrieveChunks starts the async retrieve of previously uploaded chunks starting from the returned files names.

func (*StorageClient) SaveChunks

func (s *StorageClient) SaveChunks(filename string, chunks [][]byte, hashedValue []byte, expire time.Duration, permission *fm.Permission, operationID *fm.ContextID) ([]string, error)

SaveChunks start the async upload of all argument passed chunks generating a single name for each one.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL