claims

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: Apache-2.0 Imports: 1 Imported by: 9

Documentation

Overview

Package claims provides information and interaction with the Zaqar API claims resource for the OpenStack Messaging service.

Example to Create a Claim on a specified Zaqar queue

createOpts := claims.CreateOpts{
	TTL:		60,
	Grace:		120,
	Limit: 		20,
}

queueName := "my_queue"

messages, err := claims.Create(messagingClient, queueName, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to get a claim for a specified Zaqar queue

queueName := "my_queue"
claimID := "123456789012345678"

claim, err := claims.Get(messagingClient, queueName, claimID).Extract()
if err != nil {
	panic(err)
}

Example to update a claim for a specified Zaqar queue

updateOpts := claims.UpdateOpts{
	TTL: 600
	Grace: 1200
}

queueName := "my_queue"

err := claims.Update(messagingClient, queueName, claimID, updateOpts).ExtractErr()
if err != nil {
	panic(err)
}

Example to delete a claim for a specified Zaqar queue

queueName := "my_queue"

err := claims.Delete(messagingClient, queueName, claimID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claim

type Claim struct {
	Age      float32    `json:"age"`
	Href     string     `json:"href"`
	Messages []Messages `json:"messages"`
	TTL      int        `json:"ttl"`
}

type CreateOpts

type CreateOpts struct {
	// Sets the TTL for the claim. When the claim expires un-deleted messages will be able to be claimed again.
	TTL int `json:"ttl,omitempty"`

	// Sets the Grace period for the claimed messages. The server extends the lifetime of claimed messages
	// to be at least as long as the lifetime of the claim itself, plus the specified grace period.
	Grace int `json:"grace,omitempty"`

	// Set the limit of messages returned by create.
	Limit int `q:"limit" json:"-"`
}

CreateOpts params to be used with Create.

func (CreateOpts) ToClaimCreateRequest

func (opts CreateOpts) ToClaimCreateRequest() (map[string]interface{}, string, error)

ToClaimCreateRequest assembles a body and URL for a Create request based on the contents of a CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToClaimCreateRequest() (map[string]interface{}, string, error)
}

CreateOptsBuilder Builder.

type CreateResult

type CreateResult struct {
	gophercloud.Result
}

CreateResult is the response of a Create operations.

func Create

func Create(client *gophercloud.ServiceClient, queueName string, opts CreateOptsBuilder) (r CreateResult)

Create creates a Claim that claims messages on a specified queue.

func (CreateResult) Extract

func (r CreateResult) Extract() ([]Messages, error)

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the result from a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.

func Delete

func Delete(client *gophercloud.ServiceClient, queueName string, claimID string) (r DeleteResult)

Delete will delete a Claim for a specified Queue.

type GetResult

type GetResult struct {
	gophercloud.Result
}

GetResult is the response of a Get operations.

func Get

func Get(client *gophercloud.ServiceClient, queueName string, claimID string) (r GetResult)

Get queries the specified claim for the specified queue.

func (GetResult) Extract

func (r GetResult) Extract() (*Claim, error)

type Messages

type Messages struct {
	Age  float32                `json:"age"`
	Href string                 `json:"href"`
	TTL  int                    `json:"ttl"`
	Body map[string]interface{} `json:"body"`
}

type UpdateOpts

type UpdateOpts struct {
	// Update the TTL for the specified Claim.
	TTL int `json:"ttl,omitempty"`

	// Update the grace period for Messages in a specified Claim.
	Grace int `json:"grace,omitempty"`
}

UpdateOpts implements UpdateOpts.

func (UpdateOpts) ToClaimUpdateMap

func (opts UpdateOpts) ToClaimUpdateMap() (map[string]interface{}, error)

ToClaimUpdateMap assembles a request body based on the contents of UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToClaimUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

type UpdateResult struct {
	gophercloud.ErrResult
}

UpdateResult is the response of a Update operations.

func Update

func Update(client *gophercloud.ServiceClient, queueName string, claimID string, opts UpdateOptsBuilder) (r UpdateResult)

Update will update the options for a specified claim.

Directories

Path Synopsis
Claims unit tests
Claims unit tests

Jump to

Keyboard shortcuts

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