Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) Acquire(rtype, state, dest string) (*common.Resource, error)
- func (c *Client) AcquireByState(state, dest string, names []string) ([]common.Resource, error)
- func (c *Client) AcquireByStateWait(ctx context.Context, state, dest string, names []string) ([]common.Resource, error)
- func (c *Client) AcquireWait(ctx context.Context, rtype, state, dest string) (*common.Resource, error)
- func (c *Client) AcquireWaitWithPriority(ctx context.Context, rtype, state, dest, requestID string) (*common.Resource, error)
- func (c *Client) AcquireWithPriority(rtype, state, dest, requestID string) (*common.Resource, error)
- func (c *Client) HasResource() bool
- func (c *Client) Metric(rtype string) (common.Metric, error)
- func (c *Client) Release(name, dest string) error
- func (c *Client) ReleaseAll(dest string) error
- func (c *Client) ReleaseOne(name, dest string) error
- func (c *Client) Reset(rtype, state string, expire time.Duration, dest string) (map[string]string, error)
- func (c *Client) SyncAll() error
- func (c *Client) Update(name, state string, userData *common.UserData) error
- func (c *Client) UpdateAll(state string) error
- func (c *Client) UpdateOne(name, state string, userData *common.UserData) error
- type DialerWithRetry
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned by Acquire() when no resources are available. ErrNotFound = errors.New("resources not found") // ErrAlreadyInUse is returned by Acquire when resources are already being requested. ErrAlreadyInUse = errors.New("resources already used by another user") // ErrContextRequired is returned by AcquireWait and AcquireByStateWait when // they are invoked with a nil context. ErrContextRequired = errors.New("context required") // ErrTypeNotFound is returned when the requested resource type (rtype) does not exist. // For this error to be returned, you must set DistinguishNotFoundVsTypeNotFound to true. ErrTypeNotFound = errors.New("resource type not found") )
var SleepFunc = time.Sleep
SleepFunc is called when requests are retried. This may be replaced in tests.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Dialer is the net.Dialer used to establish connections to the remote // boskos endpoint. Dialer DialerWithRetry // DistinguishNotFoundVsTypeNotFound, if set, will make it possible to distinguish between // ErrNotFound and ErrTypeNotFound. For backwards-compatibility, this flag is off by // default. DistinguishNotFoundVsTypeNotFound bool // contains filtered or unexported fields }
Client defines the public Boskos client object
func NewClient ¶
NewClient creates a Boskos client for the specified URL and resource owner.
Clients created with this function default to retrying failed connection attempts three times with a ten second pause between each attempt.
func NewClientWithPasswordGetter ¶
func NewClientWithPasswordGetter(owner string, urlString, username string, passwordGetter func() []byte) (*Client, error)
NewClientWithPasswordGetter creates a Boskos client for the specified URL and resource owner.
Clients created with this function default to retrying failed connection attempts three times with a ten second pause between each attempt.
func (*Client) Acquire ¶
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 ¶
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) AcquireByStateWait ¶
func (c *Client) AcquireByStateWait(ctx context.Context, state, dest string, names []string) ([]common.Resource, error)
AcquireByStateWait blocks until AcquireByState returns the specified resource(s) or the provided context is cancelled or its deadline exceeded.
func (*Client) AcquireWait ¶
func (c *Client) AcquireWait(ctx context.Context, rtype, state, dest string) (*common.Resource, error)
AcquireWait blocks until Acquire returns the specified resource or the provided context is cancelled or its deadline exceeded.
func (*Client) AcquireWaitWithPriority ¶
func (c *Client) AcquireWaitWithPriority(ctx context.Context, rtype, state, dest, requestID string) (*common.Resource, error)
AcquireWaitWithPriority blocks until Acquire returns the specified resource or the provided context is cancelled or its deadline exceeded. This allows you to pass in a request priority. Boskos Priority are FIFO.
func (*Client) AcquireWithPriority ¶
func (c *Client) AcquireWithPriority(rtype, state, dest, requestID string) (*common.Resource, error)
AcquireWithPriority asks boskos for a resource of certain type in certain state, and set the resource to dest state. Returns the resource on success. Boskos Priority are FIFO.
func (*Client) HasResource ¶
HasResource tells if current client holds any resources
func (*Client) Metric ¶
Metric will query current metric for target resource type. Return a common.Metric object on success.
func (*Client) ReleaseAll ¶
ReleaseAll returns all resources hold by the client back to boskos and set them to dest state.
func (*Client) ReleaseOne ¶
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.
type DialerWithRetry ¶
type DialerWithRetry struct { net.Dialer // RetryCount is the number of times to retry a connection attempt. RetryCount uint // RetrySleep is the length of time to pause between retry attempts. RetrySleep time.Duration }
DialerWithRetry is a composite version of the net.Dialer that retries connection attempts.
func (*DialerWithRetry) Dial ¶
func (d *DialerWithRetry) Dial(network, address string) (net.Conn, error)
Dial connects to the address on the named network.
func (*DialerWithRetry) DialContext ¶
func (d *DialerWithRetry) DialContext(ctx context.Context, network, address string) (net.Conn, error)
DialContext connects to the address on the named network using the provided context.