Giter VIP home page Giter VIP logo

relay's Introduction

Relay

Relay Logo

go report

Relay is a web server for forwarding events from service A to service B. While forwarding the event, it allows injecting arbitrary logic for processing the event such as filtering and augmenting.

You may think Relay as a very very simplified version of self hosted Zapier.

Overview

Overview

Relay Contains 2 components, Hooker and Sinker.

Hooker - Receive the webhook event from upstream services such as GitHub, GitLab, do some processing, and pass the processed payload to Sinker.

Sinker - Receive the payload from Hooker, do some processing, and send the event to downstream services such as Slack, Lark.

To relay an event from Service A to Service B, you would

  1. Implement a Hooker to receive event from service A.
  2. Implement a Sinker to process payload from that Hooker and send the processed message to Service B.
  3. Register the Hooker to listen to event from service A and register the Sinker with the Hooker.

Common Flags

--address (Env RELAY_ADDR)

The address where Relay runs. Default localhost:5678.

Supported Hookers

GitHub

When configuring GitHub Webhook, make sure to set the webhook content type as application/json.

Flags

--github-ref-prefix

The prefix for the GitHub ref. GitHub Webhook iteself doesn't allow to specify a particular branch or branch filter. You can use --github-ref-prefix to only observe the events from the interested branch(es).

Gerrit

Flags

Currently we only support monitor one branch in one repository.

--gerrit-repository

Target repository. Will ignore the webhook message if the repository mismatched.

--gerrit-branch

Target branch in the repository. Will ignore the webhook message if the branch mismatched.

--gerrit-url

The Gerrit service URL. We need to call the Gerrit service to list files in the change, and get the file content in the change.

--gerrit-account

The Gerrit account name.

--gerrit-password

The Gerrit account password.

Supported Sinkers

Lark

Flags

--lark-urls

A comma-separated list of Lark message group webhook URLs.

Bytebase

The Bytebase sinker will receive messages from the Gerrit hook, then create the issue for the SQL change.

--bytebase-url

The Bytebase service URL. You can use the external URL in production. Check the docs about external URL: https://www.bytebase.com/docs/get-started/install/external-url

--bytebase-service-account

The Bytebase service account. Used to call the Bytebase OpenAPI.

--bytebase-service-key

The Bytebase service key. Used to call the Bytebase OpenAPI.

Quickstart

$ go run main.go --github-ref-prefix="refs/heads/release/" --lark-urls="https://open.feishu.cn/open-apis/bot/v2/hook/foo" --gerrit-account="<gerrit-account>" --gerrit-password="<gerrit-password>" --gerrit-repository="<gerrit-repository>" --gerrit-branch="<gerrit-branch>" --bytebase-url="https://bytebase.example.com" --bytebase-service-account="<bytebase-service-account>" --bytebase-service-key="<bytebase-service-key>"

# --lark-url can also be a comma separated list
$ go run main.go --github-ref-prefix="refs/heads/release/" --lark-urls="https://open.feishu.cn/open-apis/bot/v2/hook/foo,https://open.feishu.cn/open-apis/bot/v2/hook/bar" --gerrit-account="<gerrit-account>" --gerrit-password="<gerrit-password>" --gerrit-repository="<gerrit-repository>" --gerrit-branch="<gerrit-branch>" --bytebase-url="https://bytebase.example.com" --bytebase-service-account="<bytebase-service-account>" --bytebase-service-key="<bytebase-service-key>"

# Runs on localhost:8080
$ go run main.go --address=localhost:8080 --github-ref-prefix="refs/heads/release/" --lark-urls="https://open.feishu.cn/open-apis/bot/v2/hook/foo" --gerrit-account="<gerrit-account>" --gerrit-password="<gerrit-password>" --gerrit-repository="<gerrit-repository>" --gerrit-branch="<gerrit-branch>" --bytebase-url="https://bytebase.example.com" --bytebase-service-account="<bytebase-service-account>" --bytebase-service-key="<bytebase-service-key>"

relay's People

Contributors

dependabot[bot] avatar ecmadao avatar tianzhou avatar unknwon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

relay's Issues

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.