github.com/maxgio92/test-infra@v0.1.0/kubetest/boskos/client/README.md (about)

     1  # Boskos Client Library
     2  
     3  Boskos client is a go client library interfaces [boskos server](../README.md).
     4  
     5  Users of boskos need to use boskos client to communicate with the deployed boskos service.
     6  
     7  # Initialize
     8  
     9  A boskos client instance is initialized with the URL of target boskos server accompanied with owner of the client.
    10  
    11  The client object looks like:
    12  
    13  ```
    14  type Client struct {
    15  	// RetryCount is the number of times an HTTP request issued by this client
    16  	// is retried when the initial request fails due an inaccessible endpoint.
    17  	RetryCount uint
    18  
    19  	// RetryDuration is the interval to wait before retrying an HTTP operation
    20  	// that failed due to an inaccessible endpoint.
    21  	RetryWait time.Duration
    22  
    23  	url       string
    24  	resources []string
    25  	owner     string
    26  }
    27  ```
    28  
    29  To create a boskos client, use `NewClient` and specify the Boskos endpoint URL and resource owner.
    30  The `NewClient` function also sets the client's `RetryCount` to `3` and `RetryWait` interval to `10s`.
    31  ```
    32  func NewClient(url string, owner string) *Client
    33  ```
    34  
    35  
    36  # API Reference
    37  
    38  ```
    39  // Acquire asks boskos for a resource of certain type in certain state, and set the resource to dest state.
    40  func (c *Client) Acquire(rtype string, state string, dest string) (string, error)
    41  
    42  // AcquireWait blocks until Acquire returns the specified resource or the
    43  // provided context is cancelled or its deadline exceeded.
    44  func (c *Client) AcquireWait(rtype string, state string, dest string) (string, error)
    45  
    46  // AcquireByState asks boskos for a resources of certain type, and set the resource to dest state.
    47  // Returns a list of resources on success.
    48  func (c *Client) AcquireByState(state, dest string, names []string) ([]common.Resource, error)
    49  
    50  // AcquireByStateWait blocks until AcquireByState returns the specified
    51  // resource(s) or the provided context is cancelled or its deadline exceeded.
    52  func (c *Client) AcquireByStateWait(ctx context.Context, state, dest string, names []string) ([]common.Resource, error)
    53  
    54  // ReleaseAll returns all resources hold by the client back to boskos and set them to dest state.
    55  func (c *Client) ReleaseAll(dest string) error
    56  
    57  // ReleaseOne returns one of owned resources back to boskos and set it to dest state.
    58  func (c *Client) ReleaseOne(name string, dest string) error
    59  
    60  // UpdateAll signals update for all resources hold by the client.
    61  func (c *Client) UpdateAll(state string) error
    62  
    63  // UpdateOne signals update for one of the resources hold by the client.
    64  func (c *Client) UpdateOne(name string, state string) error
    65  
    66  // Reset will scan all boskos resources of type, in state, last updated before expire, and set them to dest state.
    67  // Returns a map of {resourceName:owner} for further actions.
    68  func (c *Client) Reset(rtype string, state string, expire time.Duration, dest string) (map[string]string, error)
    69  ```