cloud

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const QueueKind = "roadie-queue"

QueueKind defines kind of entries stored in cloud datastore.

Variables

This section is empty.

Functions

func CreateInstance

func CreateInstance(ctx context.Context, name string, metadata []*MetadataItem, disksize int64) (err error)

CreateInstance creates a new instance based on the bilder's configuration.

func DeleteInstance

func DeleteInstance(ctx context.Context, name string) (err error)

DeleteInstance deletes a given named instance.

Types

type CloudStorageService

type CloudStorageService struct {
	// contains filtered or unexported fields
}

CloudStorageService object.

func NewCloudStorageService

func NewCloudStorageService(ctx context.Context) *CloudStorageService

NewCloudStorageService creates a new storage accessor to a bucket name under the given contest. The context must have a config.

func (*CloudStorageService) CreateIfNotExists

func (s *CloudStorageService) CreateIfNotExists() (err error)

CreateIfNotExists creates the bucket if not exists.

func (*CloudStorageService) Delete

func (s *CloudStorageService) Delete(name string) (err error)

Delete deletes a given file.

func (*CloudStorageService) Download

func (s *CloudStorageService) Download(filename string, out io.Writer) (err error)

Download downloads a file and write it to a given writer.

func (*CloudStorageService) List

func (s *CloudStorageService) List(prefix string, handler FileInfoHandler) error

List searches items, i.e. files and folders, matching a given prefix. Found items will be passed to a given handler item by item. If the handler returns a non nil value, listing up will be canceled. In that case, this function will also return the given value.

func (*CloudStorageService) Status

func (s *CloudStorageService) Status(filename string) (info *FileInfo, err error)

Status returns a file status of an object.

func (*CloudStorageService) Upload

func (s *CloudStorageService) Upload(in io.Reader, location *url.URL) (err error)

Upload a file to a location.

type Datastore added in v0.3.0

type Datastore struct {
	// contains filtered or unexported fields
}

func NewDatastore added in v0.3.0

func NewDatastore(ctx context.Context) *Datastore

NewDatastore creates a new datastore interface, It requires a context which has a config object.

func (*Datastore) FindTasks added in v0.3.0

func (d *Datastore) FindTasks(name string, handler func(*resource.Task) error) (err error)

FindTasks lists up tasks in a given named queue. Founded tasks will be passed to a given handler function. If the hunder function returns non-nil error, the listing up will be stopped.

func (*Datastore) Insert added in v0.3.0

func (d *Datastore) Insert(id int64, task *resource.Task) (err error)

func (*Datastore) QueueNames added in v0.3.0

func (d *Datastore) QueueNames(handler func(string) error) (err error)

QueueNames lists up queue names. Founded names are passed to a given handler function. If the handler returns non-nil error, listing up will be stopped.

func (*Datastore) UpdateTasks added in v0.3.0

func (d *Datastore) UpdateTasks(name string, handler func(*resource.Task) (*resource.Task, error)) (err error)

UpdateTasks updates tasks in a given named queue. Each task will be passed to a given handler. The handler should return modified tasks. If the handler returns non-nil error, the update will be stopped.

type FileInfo

type FileInfo struct {
	Name        string
	Path        string
	TimeCreated time.Time
	Size        uint64
}

FileInfo defines file information structure.

func NewFileInfo

func NewFileInfo(f *storage.Object) *FileInfo

NewFileInfo creates a file info from an object.

type FileInfoHandler

type FileInfoHandler func(*FileInfo) error

FileInfoHandler is a handler to recieve a file info.

type MachineType

type MachineType struct {
	Name        string
	Description string
}

MachineType defines a structure of machine type infoemation.

func AvailableMachineTypes

func AvailableMachineTypes(ctx context.Context) (types []MachineType, err error)

AvailableMachineTypes returns a slice of machie type names.

type MetadataItem

type MetadataItem struct {
	Key   string
	Value string
}

MetadataItem has Key and Value properties.

type QueueName added in v0.3.0

type QueueName struct {
	// Queue name.
	QueueName string
}

QueueName is a structure to obtaine QueueName attribute from entities in cloud datastore.

type Storage

type Storage struct {

	// Writer logs to be printed.
	Log io.Writer
	// contains filtered or unexported fields
}

Storage provides APIs to access a cloud storage.

func NewStorage

func NewStorage(ctx context.Context) *Storage

NewStorage creates a cloud storage accessor with a given context. The context must have a Config.

func (*Storage) DeleteFiles

func (s *Storage) DeleteFiles(prefix string, queries []string) error

DeleteFiles deletes files in a bucket associated with a project, which has a prefix and satisfies a query. This request will be done under a given context.

func (*Storage) DownloadFiles

func (s *Storage) DownloadFiles(prefix, dir string, queries []string) (err error)

DownloadFiles downloads files in a bucket associated with a project, which has a prefix and satisfies a query under a given context. Downloaded files will be put in a given directory.

func (*Storage) ListupFiles

func (s *Storage) ListupFiles(prefix string, handler FileInfoHandler) (err error)

ListupFiles lists up files in a bucket associated with a project and which have a prefix under a given context. Information of found files will be passed to a handler. If the handler returns non nil value, the listing up will be canceled. In this case, this function also returns the given error value.

func (*Storage) PrepareBucket

func (s *Storage) PrepareBucket() error

PrepareBucket makes a bucket if it doesn't exist under a given context. The given context must have a config.

func (*Storage) PrintFileBody

func (s *Storage) PrintFileBody(prefix, query string, output io.Writer, header bool) error

PrintFileBody prints file bodies which has a prefix and satisfies query under a context. If header is ture, additional messages well be printed.

func (*Storage) UploadFile

func (s *Storage) UploadFile(prefix, name, input string) (string, error)

UploadFile uploads a file to a bucket associated with a project under a given context. Uploaded file will have a given name. This function returns a URL for the uploaded file with error object.

type Zone

type Zone struct {
	Name   string
	Status string
}

Zone defines a structure of zone information.

func AvailableZones

func AvailableZones(ctx context.Context) (zones []Zone, err error)

AvailableZones returns a slice of zone names.

Jump to

Keyboard shortcuts

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