github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dis/v2/checkpoints/GetCheckpoint.go (about)

     1  package checkpoints
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  type GetCheckpointOpts struct {
     9  	// Name of the stream to which the checkpoint belongs.
    10  	StreamName string `q:"stream_name"`
    11  	// Identifier of the stream partition to which the checkpoint belongs.
    12  	// The value can be in either of the following formats:
    13  	//  - shardId-0000000000
    14  	//  - 0
    15  	// For example, if a stream has three partitions, the partition identifiers are 0, 1, and 2,
    16  	// or shardId-0000000000, shardId-0000000001, and shardId-0000000002, respectively.
    17  	PartitionId string `q:"partition_id"`
    18  	// Name of the app associated with the checkpoint.
    19  	AppName string `q:"app_name"`
    20  	// Type of the checkpoint.
    21  	// LAST_READ: Only sequence numbers are recorded in databases.
    22  	// Enumeration values:
    23  	// LAST_READ
    24  	CheckpointType string `q:"checkpoint_type"`
    25  }
    26  
    27  func GetCheckpoint(client *golangsdk.ServiceClient, opts GetCheckpointOpts) (*GetCheckpointResponse, error) {
    28  	url, err := golangsdk.NewURLBuilder().WithEndpoints("checkpoints").WithQueryParams(&opts).Build()
    29  	if err != nil {
    30  		return nil, err
    31  	}
    32  
    33  	// GET /v2/{project_id}/checkpoints
    34  	raw, err := client.Get(client.ServiceURL(url.String()), nil, nil)
    35  	if err != nil {
    36  		return nil, err
    37  	}
    38  
    39  	var res GetCheckpointResponse
    40  	err = extract.Into(raw.Body, &res)
    41  	return &res, err
    42  }
    43  
    44  type GetCheckpointResponse struct {
    45  	// Sequence number used to record the consumption checkpoint of the stream.
    46  	SequenceNumber string `json:"sequence_number,omitempty"`
    47  	// Metadata information of the consumer application.
    48  	Metadata string `json:"metadata,omitempty"`
    49  }