Documentation
¶
Overview ¶
Package cloud wraps Google Cloud Platform APIs and provides functions to use it.
Index ¶
- type FileInfo
- type FileInfoHandler
- type InstanceHandler
- type InstanceManager
- type LogHandler
- type LogManager
- type MachineType
- type MetadataItem
- type Provider
- type QueueManager
- type QueueManagerNameHandler
- type QueueManagerTaskHandler
- type QueueStatus
- type QueueStatusHandler
- type Region
- type ResourceManager
- type Storage
- func (s *Storage) DeleteFiles(ctx context.Context, prefix *url.URL, queries []string) (err error)
- func (s *Storage) DownloadFiles(ctx context.Context, prefix *url.URL, dir string, queries []string) (err error)
- func (s *Storage) ListupFiles(ctx context.Context, loc *url.URL, handler FileInfoHandler) (err error)
- func (s *Storage) PrintFileBody(ctx context.Context, prefix *url.URL, query string, output io.Writer, ...) error
- func (s *Storage) UploadFile(ctx context.Context, loc *url.URL, input string) (err error)
- type StorageManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileInfo ¶
type FileInfo struct {
// Name of the file, which means the base name.
Name string
// URL of the file. The scheme should be roadie://.
URL *url.URL
// TimeCreated is the time when the file was created.
TimeCreated time.Time
// Size of the file.
Size int64
}
FileInfo defines file information structure.
type FileInfoHandler ¶
FileInfoHandler is a handler to receive a file info.
type InstanceHandler ¶ added in v0.3.5
InstanceHandler is a handler function to retrive instances' status.
type InstanceManager ¶ added in v0.3.5
type InstanceManager interface {
// CreateInstance creates an instance which has a given name.
CreateInstance(ctx context.Context, script *script.Script) error
// DeleteInstance deletes the given named instance.
DeleteInstance(ctx context.Context, name string) error
// Instances returns a list of running instances
Instances(ctx context.Context, handler InstanceHandler) error
}
InstanceManager is a service interface of an instance manager.
type LogHandler ¶ added in v0.3.5
LogHandler defines a hanler function for log entries.
type LogManager ¶ added in v0.3.5
type LogManager interface {
// Get instance log.
Get(ctx context.Context, instanceName string, after time.Time, handler LogHandler) error
// Delete instance log.
Delete(ctx context.Context, instanceName string) error
// GetQueueLog retrievs log entries from a given queue.
GetQueueLog(ctx context.Context, queue string, handler LogHandler) error
// GetTaskLog retrieves log entries from a task in a queue.
GetTaskLog(ctx context.Context, queue, task string, handler LogHandler) error
}
LogManager defines a service interface for obtaining log entries.
type MachineType ¶
MachineType defines a structure of machine type infoemation.
type MetadataItem ¶
MetadataItem has Key and Value properties.
type Provider ¶ added in v0.3.5
type Provider interface {
// InstanceManager returns an instance manager interface.
InstanceManager(context.Context) (InstanceManager, error)
// QueueManager returns a queue manager interface.
QueueManager(context.Context) (QueueManager, error)
// StorageManager returns a storage manager interface.
StorageManager(context.Context) (StorageManager, error)
// LogManager returns a log manager interface.
LogManager(context.Context) (LogManager, error)
// ResourceManager returns a resource manager interface.
ResourceManager(context.Context) (ResourceManager, error)
}
Provider is an interface of cloud service provider.
type QueueManager ¶ added in v0.3.5
type QueueManager interface {
// Enqueue a new task to a given named queue.
Enqueue(ctx context.Context, queue string, task *script.Script) error
// Tasks retrieves tasks in a given names queue.
Tasks(ctx context.Context, queue string, handler QueueManagerTaskHandler) error
// Queues retrieves existing queue names.
Queues(ctx context.Context, handler QueueStatusHandler) error
// Stop executing tasks in a given named queue.
Stop(ctx context.Context, queue string) error
// Restart executing tasks in a given names queue.
Restart(ctx context.Context, queue string) error
// CreateWorkers creates worker instances working for a given named queue.
CreateWorkers(ctx context.Context, queue string, n int, handler QueueManagerNameHandler) error
// Workers retrieves worker instance names for a given queue.
Workers(ctx context.Context, queue string, handler QueueManagerNameHandler) error
// DeleteQueue deletes a given named queue.
DeleteQueue(ctx context.Context, queue string) error
// DeleteTask deletes a given named task in a given named queue.
DeleteTask(ctx context.Context, queue, task string) error
}
QueueManager is a service interface of a queuing task manager.
type QueueManagerNameHandler ¶ added in v0.3.5
QueueManagerNameHandler is a type of handler function to retrieve names.
type QueueManagerTaskHandler ¶ added in v0.3.5
QueueManagerTaskHandler is a type of handler function to retrieve tasks.
type QueueStatus ¶ added in v0.3.11
type QueueStatus struct {
// The number of waiting tasks.
Waiting int
// The number of pending tasks.
Pending int
// The number of running tasks.
Running int
// The number of worker instances.
Worker int
}
QueueStatus holds the numbers of waiting, pending, and running tasks in a queue. It also has the number of workers working for the queue, too.
type QueueStatusHandler ¶ added in v0.3.5
type QueueStatusHandler func(name string, status QueueStatus) error
QueueStatusHandler is a type of handler function to retrieve queues' stauts.
type ResourceManager ¶ added in v0.3.5
type ResourceManager interface {
// GetProjectID returns an ID of the current project.
GetProjectID() string
// SetProjectID sets an ID to the current project.
SetProjectID(string)
// GetMachineType returns a machine type the current project uses by default.
GetMachineType() string
// SetMachineType sets a machine type as the default one.
SetMachineType(string)
// MachineTypes returns a set of available machine types.
MachineTypes(context.Context) ([]MachineType, error)
// GetRegion returns a region name the current project working on.
GetRegion() string
// SetRegion sets a region to the current project.
SetRegion(string)
// Regions returns a set of available regions.
Regions(context.Context) ([]Region, error)
}
ResourceManager defines an interface for configuration to use a cloud service.
type Storage ¶
type Storage struct {
// TODO: Delete or update this.
// 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(servicer StorageManager, log io.Writer) (s *Storage)
NewStorage creates a cloud storage accessor with a given context.
func (*Storage) DeleteFiles ¶
DeleteFiles deletes files matching a given URL prefix and queries.
func (*Storage) DownloadFiles ¶
func (s *Storage) DownloadFiles(ctx context.Context, prefix *url.URL, dir string, queries []string) (err error)
DownloadFiles downloads files matching a given prefix and queries. Downloaded files will be put in a given directory.
func (*Storage) ListupFiles ¶
func (s *Storage) ListupFiles(ctx context.Context, loc *url.URL, handler FileInfoHandler) (err error)
ListupFiles lists up files which location is matching to a given URL. 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.
type StorageManager ¶ added in v0.3.5
type StorageManager interface {
// Upload a given stream to a given URL.
Upload(ctx context.Context, loc *url.URL, in io.Reader) error
// Download a file pointed by a given URL and write it to a given stream.
Download(ctx context.Context, loc *url.URL, out io.Writer) error
// GetFileInfo retrieves information of a file pointed by a given URL.
GetFileInfo(ctx context.Context, loc *url.URL) (*FileInfo, error)
// List up files of which URLs start with a given URL.
// It takes a handler; information of found files are sent to it.
List(ctx context.Context, loc *url.URL, handler FileInfoHandler) error
// Delete a file pointed by a given URL.
Delete(ctx context.Context, loc *url.URL) error
}
StorageManager defines methods which a storage service provider must provides. Each method takes a URL to point a file stored in this storage. The URL should be - roadie://category/path where category is one of - script.SourcePrefix - script.DataPrefix - script.ResultPrefix
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gcp provides implementations of interfaces defined in cloud package.
|
Package gcp provides implementations of interfaces defined in cloud package. |
|
Package mock provides a mock service provider which implements cloud.Provider interface.
|
Package mock provides a mock service provider which implements cloud.Provider interface. |