Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kedacore/sample-go-storage-queue
KEDA Azure Storage Queue Trigger Samples
https://github.com/kedacore/sample-go-storage-queue
Last synced: 4 days ago
JSON representation
KEDA Azure Storage Queue Trigger Samples
- Host: GitHub
- URL: https://github.com/kedacore/sample-go-storage-queue
- Owner: kedacore
- Created: 2020-08-18T21:00:38.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-25T07:55:58.000Z (almost 3 years ago)
- Last Synced: 2024-06-21T16:45:58.827Z (5 months ago)
- Language: Go
- Size: 7.81 KB
- Stars: 1
- Watchers: 8
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# KEDA Azure Storage Queue Trigger Samples
Sample program for sending/receiving queue and KEDA v2 Azure Storage Queue Trigger.
# How to run the sample
## Prerequisite
* Install Go lang (1.13+)
* Docker## Set Environment Variables for the container
| Key | Description |
| ---- | ------ |
| ConnectionString | The Connection String for the Azure Storage Account |
| queueName | The name of the queue |## Run queue receiver/sender
### receiver
Receive queue messages.
```bash
$ cd cmd/receive
$ go run receive.go
```### sender
Send 100 messages to the Azure Storage Queue.
```bash
$ cd cmd/send
$ go run send.go 100
```# How to debug
To see the behavior, you can debug it. This is the sample of the VSCode `.vscode/launch.json`. Then Start Debugging.
It requires, VSCode [Go extension](https://marketplace.visualstudio.com/items?itemName=golang.Go).```json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {
"ConnectionString": "YOUR_STORAGE_ACCOUNT_CONNECTION_STRING_HERE",
"QueueName":"hello"
},
"args": []
}
]
}
```## Run with KEDA
### Prerequisite
KEDA v2 is deployed already.
You have a kubernetes cluster and configured with kubectl.### Start the ScaledJob
#### Copy deploy-consumer-job.yaml.example to deploy-consumer-job.yaml
Modify `YOUR_BASE64_CONNECTION_STRING_HERE` as your Storage Account Connection String with Base64 encoded.Then Apply it. This will create a secret, ScaledJob with Storage Queue Trigger.
```
$ kubectl apply -f deploy/deploy-consumer-job.yaml
```Send queue to the target queue. You can do it with the `send` command. This command will send 3 messages with cleaning up existing messages.
```
$ cd cmd/send
$ export ConnectionString="YOUR_CONNECTION_STRING_HERE"
$ export queueName=hello
$ go run send.go 3
```