services

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2019 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PENDING = "PENDING"
	SUCCESS = "SUCCESS"
	FAILED  = "FAILED"
)

Task status

View Source
const DEFAULT_POLLING_INTERVAL = 1000

Variables

This section is empty.

Functions

This section is empty.

Types

type EntityApi

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

Implementation of the EntityService

func (*EntityApi) Create

func (entityApi *EntityApi) Create(body []byte, options map[string]string) ([]byte, error)

Create a new entity described in the body parameter (json object). Returns a []byte (of a json object) that should be unmarshalled to a specific entity

func (EntityApi) Delete

func (entityApi EntityApi) Delete(id string, body []byte, options map[string]string) ([]byte, error)

Delete specified id described. A body (json object) can be provided if some fields must be sent to server. Returns a []byte (of a json object) that should be unmarshalled to a specific entity

func (*EntityApi) Execute

func (entityApi *EntityApi) Execute(id string, operation string, body []byte, options map[string]string) ([]byte, error)

Execute a specific operation on an entity. Returns a []byte (of a json object) that should be unmarshalled to a specific entity

func (*EntityApi) Get

func (entityApi *EntityApi) Get(id string, options map[string]string) ([]byte, error)

Get an entity. Returns a []byte (of a json object) that should be unmarshalled to a specific entity

func (*EntityApi) List

func (entityApi *EntityApi) List(options map[string]string) ([]byte, error)

Get an entity list. Returns a []byte (of a json object) that should be unmarshalled to a specific entity

func (*EntityApi) Update

func (entityApi *EntityApi) Update(id string, body []byte, options map[string]string) ([]byte, error)

Update entity with specified id described in the body parameter (json object). Returns a []byte (of a json object) that should be unmarshalled to a specific entity

type EntityService

type EntityService interface {
	Get(id string, options map[string]string) ([]byte, error)
	List(options map[string]string) ([]byte, error)
	Execute(id string, operation string, body []byte, options map[string]string) ([]byte, error)
	Create(body []byte, options map[string]string) ([]byte, error)
	Update(id string, body []byte, options map[string]string) ([]byte, error)
	Delete(id string, body []byte, options map[string]string) ([]byte, error)
}

A generic service to access any entity

func NewEntityService

func NewEntityService(apiClient api.ApiClient, serviceCode string, environmentName string, entityType string) EntityService

type FailedTask

type FailedTask Task

func (FailedTask) Error

func (ft FailedTask) Error() string

type ServiceResources

type ServiceResources interface {
	GetServiceType() string
}

Holds all the resources available for a particular service

type Task

type Task struct {
	Id      string
	Status  string
	Created string
	Result  []byte
}

A Task object. This object can be used to poll asynchronous operations.

func (Task) Completed

func (task Task) Completed() bool

Returns true if task has completed its execution

func (Task) Failed

func (task Task) Failed() bool

Returns true if task has failed

func (Task) Pending

func (task Task) Pending() bool

Returns true if task is still executing

func (Task) Success

func (task Task) Success() bool

Returns true if task was successful

type TaskApi

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

func (*TaskApi) Get

func (taskApi *TaskApi) Get(id string) (*Task, error)

Retrieve a Task with sepecified id

func (*TaskApi) Poll

func (taskApi *TaskApi) Poll(id string, milliseconds time.Duration) ([]byte, error)

Poll an the Task API. Blocks until success or failure. Returns result on success, an error otherwise

func (*TaskApi) PollResponse

func (taskApi *TaskApi) PollResponse(response *api.CcaResponse, milliseconds time.Duration) ([]byte, error)

Poll an the Task API. Blocks until success or failure

type TaskService

type TaskService interface {
	Get(id string) (*Task, error)
	Poll(id string, milliseconds time.Duration) ([]byte, error)
	PollResponse(response *api.CcaResponse, milliseconds time.Duration) ([]byte, error)
}

func NewTaskService

func NewTaskService(apiClient api.ApiClient) TaskService

Create a new TaskService

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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