Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/storage/azqueue/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/storage/azqueue",
"Tag": "go/storage/azqueue_d0cbfd994e"
"Tag": "go/storage/azqueue_250a75f53b"
}
2 changes: 1 addition & 1 deletion sdk/storage/azqueue/internal/base/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewServiceClient(queueURL string, pipeline runtime.Pipeline, sharedKey *exp
func NewQueueClient(queueURL string, pipeline runtime.Pipeline, sharedKey *exported.SharedKeyCredential) *CompositeClient[generated.QueueClient, generated.MessagesClient] {
return &CompositeClient[generated.QueueClient, generated.MessagesClient]{
innerT: generated.NewQueueClient(queueURL, pipeline),
innerU: generated.NewMessagesClient(queueURL, pipeline),
innerU: generated.NewMessagesClient(runtime.JoinPaths(queueURL, "messages"), pipeline),
sharedKey: sharedKey,
}
}
Expand Down
3 changes: 2 additions & 1 deletion sdk/storage/azqueue/internal/testcommon/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (
)

const (
QueuePrefix = "goq"
QueuePrefix = "goq"
QueueDefaultData = "this is some default data"
)

func GenerateQueueName(testName string) string {
Expand Down
43 changes: 30 additions & 13 deletions sdk/storage/azqueue/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,6 @@ type GetAccessPolicyOptions struct {
}

func (o *GetAccessPolicyOptions) format() *generated.QueueClientGetAccessPolicyOptions {
if o == nil {
return nil
}

return nil
}

Expand Down Expand Up @@ -314,7 +310,15 @@ func (o *GetQueuePropertiesOptions) format() *generated.QueueClientGetProperties

// EnqueueMessageOptions contains the optional parameters for the QueueClient.EnqueueMessage method.
type EnqueueMessageOptions struct {
TimeToLive *int32
// Specifies the time-to-live interval for the message, in seconds.
// The time-to-live may be any positive number or -1 for infinity.
// If this parameter is omitted, the default time-to-live is 7 days.
TimeToLive *int32
// If not specified, the default value is 0.
// Specifies the new visibility timeout value, in seconds, relative to server time.
// The value must be larger than or equal to 0, and cannot be larger than 7 days.
// The visibility timeout of a message cannot be set to a value later than the expiry time.
// VisibilityTimeout should be set to a value smaller than the time-to-live value.
VisibilityTimeout *int32
}

Expand All @@ -329,8 +333,13 @@ func (o *EnqueueMessageOptions) format() *generated.MessagesClientEnqueueOptions

// ---------------------------------------------------------------------------------------------------------------------

// DequeueMessageOptions contains the optional parameters for the QueueClient.EnqueueMessage method.
// DequeueMessageOptions contains the optional parameters for the QueueClient.DequeueMessage method.
type DequeueMessageOptions struct {
// If not specified, the default value is 0. Specifies the new visibility timeout value,
// in seconds, relative to server time. The value must be larger than or equal to 0, and cannot be
// larger than 7 days. The visibility timeout of a message cannot be
// set to a value later than the expiry time. VisibilityTimeout
// should be set to a value smaller than the time-to-live value.
VisibilityTimeout *int32
}

Expand All @@ -348,7 +357,16 @@ func (o *DequeueMessageOptions) format() *generated.MessagesClientDequeueOptions

// DequeueMessagesOptions contains the optional parameters for the QueueClient.DequeueMessages method.
type DequeueMessagesOptions struct {
NumberOfMessages *int32
// Optional. A nonzero integer value that specifies the number of messages to retrieve from the queue,
// up to a maximum of 32. If fewer messages are visible, the visible messages are returned.
// By default, a single message is retrieved from the queue with this operation.
NumberOfMessages *int32
// If not specified, the default value is 30. Specifies the
// new visibility timeout value, in seconds, relative to server time.
// The value must be larger than or equal to 1, and cannot be
// larger than 7 days. The visibility timeout of a message cannot be
// set to a value later than the expiry time. VisibilityTimeout
// should be set to a value smaller than the time-to-live value.
VisibilityTimeout *int32
}

Expand All @@ -369,10 +387,13 @@ type UpdateMessageOptions struct {
}

func (o *UpdateMessageOptions) format() *generated.MessageIDClientUpdateOptions {
defaultVT := to.Ptr(int32(0))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting it to just 'nil' won't work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no :(

if o == nil {
return nil
return &generated.MessageIDClientUpdateOptions{Visibilitytimeout: defaultVT}
}
if o.VisibilityTimeout == nil {
o.VisibilityTimeout = defaultVT
}

return &generated.MessageIDClientUpdateOptions{Visibilitytimeout: o.VisibilityTimeout}
}

Expand All @@ -398,10 +419,6 @@ type PeekMessageOptions struct {

func (o *PeekMessageOptions) format() *generated.MessagesClientPeekOptions {
numberOfMessages := int32(1)
if o == nil {
return &generated.MessagesClientPeekOptions{NumberOfMessages: &numberOfMessages}
}

return &generated.MessagesClientPeekOptions{NumberOfMessages: &numberOfMessages}
}

Expand Down
10 changes: 6 additions & 4 deletions sdk/storage/azqueue/queue_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ func (q *QueueClient) messagesClient() *generated.MessagesClient {
return messages
}

func (q *QueueClient) getMessageIDURL(messageID string) string {
return runtime.JoinPaths(q.queueClient().Endpoint(), "messages", messageID)
}

func (q *QueueClient) sharedKey() *SharedKeyCredential {
return base.SharedKeyComposite((*base.CompositeClient[generated.QueueClient, generated.MessagesClient])(q))
}
Expand Down Expand Up @@ -171,8 +175,7 @@ func (q *QueueClient) DequeueMessage(ctx context.Context, o *DequeueMessageOptio
func (q *QueueClient) UpdateMessage(ctx context.Context, messageID string, popReceipt string, content string, o *UpdateMessageOptions) (UpdateMessageResponse, error) {
opts := o.format()
message := generated.QueueMessage{MessageText: &content}
messageURL := runtime.JoinPaths(q.queueClient().Endpoint(), messageID)
messageClient := generated.NewMessageIDClient(messageURL, q.queueClient().Pipeline())
messageClient := generated.NewMessageIDClient(q.getMessageIDURL(messageID), q.queueClient().Pipeline())
resp, err := messageClient.Update(ctx, popReceipt, message, opts)
return resp, err
}
Expand All @@ -181,8 +184,7 @@ func (q *QueueClient) UpdateMessage(ctx context.Context, messageID string, popRe
// For more information, see https://learn.microsoft.com/en-us/rest/api/storageservices/delete-message2.
func (q *QueueClient) DeleteMessage(ctx context.Context, messageID string, popReceipt string, o *DeleteMessageOptions) (DeleteMessageResponse, error) {
opts := o.format()
messageURL := runtime.JoinPaths(q.queueClient().Endpoint(), messageID)
messageClient := generated.NewMessageIDClient(messageURL, q.queueClient().Pipeline())
messageClient := generated.NewMessageIDClient(q.getMessageIDURL(messageID), q.queueClient().Pipeline())
resp, err := messageClient.Delete(ctx, popReceipt, opts)
return resp, err
}
Expand Down
Loading