client

package
v0.0.0-...-d7867ec Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

README

Boskos Client Library

Boskos client is a go client library interfaces boskos server.

Users of boskos need to use boskos client to communicate with the deployed boskos service.

Initialize

A boskos client instance is initialized with the URL of target boskos server accompanied with owner of the client.

The client object looks like:

type Client struct {
	url       string
	resources []string
	owner     string
}

To create a boskos client, use NewClient func, specify boskos server url, and owner of the client:

func NewClient(url string, owner string) *Client

API Reference

// Acquire asks boskos for a resource of certain type in certain state, and set the resource to dest state.
func (c *Client) Acquire(rtype string, state string, dest string) (string, error)

// ReleaseAll returns all resources hold by the client back to boskos and set them to dest state.
func (c *Client) ReleaseAll(dest string) error

// ReleaseOne returns one of owned resources back to boskos and set it to dest state.
func (c *Client) ReleaseOne(name string, dest string) error

// UpdateAll signals update for all resources hold by the client.
func (c *Client) UpdateAll(state string) error

// UpdateOne signals update for one of the resources hold by the client.
func (c *Client) UpdateOne(name string, state string) error

// Reset will scan all boskos resources of type, in state, last updated before expire, and set them to dest state.
// Returns a map of {resourceName:owner} for further actions.
func (c *Client) Reset(rtype string, state string, expire time.Duration, dest string) (map[string]string, error)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client defines the public Boskos client object

func NewClient

func NewClient(owner string, url string) *Client

NewClient creates a boskos client, with boskos url and owner of the client.

func (*Client) Acquire

func (c *Client) Acquire(rtype, state, dest string) (*common.Resource, error)

Acquire asks boskos for a resource of certain type in certain state, and set the resource to dest state. Returns the resource on success.

func (*Client) AcquireByState

func (c *Client) AcquireByState(state, dest string, names []string) ([]common.Resource, error)

AcquireByState asks boskos for a resources of certain type, and set the resource to dest state. Returns a list of resources on success.

func (*Client) HasResource

func (c *Client) HasResource() bool

HasResource tells if current client holds any resources

func (*Client) Metric

func (c *Client) Metric(rtype string) (common.Metric, error)

Metric will query current metric for target resource type. Return a common.Metric object on success.

func (*Client) ReleaseAll

func (c *Client) ReleaseAll(dest string) error

ReleaseAll returns all resources hold by the client back to boskos and set them to dest state.

func (*Client) ReleaseOne

func (c *Client) ReleaseOne(name, dest string) error

ReleaseOne returns one of owned resources back to boskos and set it to dest state.

func (*Client) Reset

func (c *Client) Reset(rtype, state string, expire time.Duration, dest string) (map[string]string, error)

Reset will scan all boskos resources of type, in state, last updated before expire, and set them to dest state. Returns a map of {resourceName:owner} for further actions.

func (*Client) SyncAll

func (c *Client) SyncAll() error

SyncAll signals update for all resources hold by the client.

func (*Client) UpdateAll

func (c *Client) UpdateAll(state string) error

UpdateAll signals update for all resources hold by the client.

func (*Client) UpdateOne

func (c *Client) UpdateOne(name, state string, userData *common.UserData) error

UpdateOne signals update for one of the resources hold by the client.

Jump to

Keyboard shortcuts

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