Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add waitTime config field to azure queue storage event source #2996

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions api/event-source.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions api/event-source.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions api/jsonschema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,11 @@
"storageAccountName": {
"description": "StorageAccountName is the name of the storage account where the queue is. This field is necessary to access via Azure AD (managed identity) and it is ignored if ConnectionString is set.",
"type": "string"
},
"waitTime": {
"description": "WaitTime is the duration (in seconds) for which the event source waits between empty results from the queue. The default value is 3 seconds.",
"format": "int32",
"type": "integer"
}
},
"required": [
Expand Down
5 changes: 5 additions & 0 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions eventsources/sources/azurequeuestorage/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func (el *EventListener) StartListening(ctx context.Context, dispatch func([]byt
}
var numMessages int32 = 10
var visibilityTimeout int32 = 120
var waitTime int32 = 3 // Defaults to 3 seconds
if el.AzureQueueStorageEventSource.WaitTime != nil {
waitTime = *el.AzureQueueStorageEventSource.WaitTime
}
log.Info("listening for messages on the queue...")
for {
select {
Expand All @@ -98,6 +102,7 @@ func (el *EventListener) StartListening(ctx context.Context, dispatch func([]byt
return nil
default:
}
log.Info("dequeing messages....")
messages, err := queueClient.DequeueMessages(ctx, &azqueue.DequeueMessagesOptions{
NumberOfMessages: &numMessages,
VisibilityTimeout: &visibilityTimeout,
Expand All @@ -115,6 +120,9 @@ func (el *EventListener) StartListening(ctx context.Context, dispatch func([]byt
}
}, log)
}
if len(messages.Messages) == 0 {
time.Sleep(time.Second * time.Duration(waitTime))
}
}
}

Expand Down
896 changes: 463 additions & 433 deletions pkg/apis/eventsource/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions pkg/apis/eventsource/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/apis/eventsource/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/apis/eventsource/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,10 @@ type AzureQueueStorageEventSource struct {
// If set to true the decoding is done before the evaluation of JSONBody
// +optional
DecodeMessage bool `json:"decodeMessage,omitempty" protobuf:"bytes,8,opt,name=decodeMessage"`
// WaitTime is the duration (in seconds) for which the event source waits between empty results from the queue.
// The default value is 3 seconds.
// +optional
WaitTime *int32 `json:"waitTime,omitempty" protobuf:"varint,9,opt,name=waitTime"`
eduardodbr marked this conversation as resolved.
Show resolved Hide resolved
}

// StripeEventSource describes the event source for stripe webhook notifications
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/eventsource/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.