GithubHelp home page GithubHelp logo

raisebook / qbot Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 509 KB

I for one, welcome our robotic Queue managing overlords

License: MIT License

Elixir 69.45% Shell 22.93% HTML 7.19% Dockerfile 0.43%

qbot's Introduction

QBot

Build status ~ Code Climate

A service that acts as a dispatcher of messages from SQS Queues to either HTTP(S) endpoints or AWS Lambda functions.

If the remote request fails, it will not be Acknowledged / Deleted on SQS, so any retry policies (including Dead Letter Queues) will be respected.

Usage

Step 1

Configure your SQS Queue with QBotEndpoint as metadata, for example, in the infrastructure repo:

Resources:
  TestingQueue:
    Type: AWS::SQS::Queue
    Metadata:
      QBotEndpoint: "https://service.api.raisebook.com/graphql"
    Properties:    
      QueueName: $(AWS::StackName)-testing-queue
      etc: ...

or

Resources:
  TestingLambdaQueue:
    Type: AWS::SQS::Queue
    Metadata:
      QBotEndpoint: $(MyFunction[Arn])
    Properties:
      QueueName: $(AWS::StackName)-testing-to-lambda
      etc: ...

If given a lambda ARN, then it will be (synchronously) invoked, and http(s) endpoints will be POST'ed to

Step 2

Either send a message to the SQS queue directly (or pass it along from an SNS Topic).

Message Format

{
  "metadata": {
    "RequestID": "12345-12345-12345-12345-12345",
    "Authorization": "Bearer myt0ken",
    "Callback": "https://raisebook.dev/graphql"
  },
  "payload": {
    "my": "json payload"
  }
}
  • Metadata block is optional
  • If there is no metadata, wrapping the payload in a "payload" key is optional
  • The payload itself should be in JSON format
  • For Lambda invocations, the message will be passed through, as-is.

Valid Metadata keys to HTTP Headers

Metadata Key HTTP Header
CorrelationUUID X-Request-ID
RequestID X-Request-ID
Request_ID X-Request-ID
X-Request-ID X-Request-ID
Authorization Authorization
Callback X-Callback

For HTTP all other metadata keys will be dropped.

Requeue items in the Dead Letter Queue

First, ensure you have exported your AWS credentials into your environment

Run qbot requeue <name of the queue>

Let it run to completion - it looks like it hangs, but there is a 20 second timeout to make sure it cleares the queue out completely.

Looking for the code for this? Checkout https://github.com/raisebook/sqs-dead-letter-handling

Raisebot

To save on typing docker-compose a thousand times a day, there is a helper application in the /bin folder. You can add PATH=./bin:$PATH to your bash_profile to speed things up even more.

Run qbot help for more information. You can run qbot help [command] for more information about a specific command.

Note: The installation guide assumes the stockroom script is in your path - if you didn't add it, run bin/qbot instead.

This tool is a fork of Sub

Installation

  1. Check out the repository git clone [email protected]:raisebook/qbot
  2. run qbot build
  3. run qbot start

ROBOT

Contributing

Please read the Licence and Code of Conduct before contributing.

Patches can be submitted by following the usual GitHub "fork -> feature branch -> pull request" dance.

Thanks.

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.