Coder Social home page Coder Social logo

sample-go-storage-queue's Introduction

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.

$ cd cmd/receive
$ go run receive.go

sender

Send 100 messages to the Azure Storage Queue.

$ 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.

{
    // 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

sample-go-storage-queue's People

Contributors

tsuyoshiushio avatar tomkerkhove avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.