• Stars
    star
    1,647
  • Rank 28,377 (Top 0.6 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React to any event with serverless functions across clouds

Event Gateway - React to any event with FaaS function across clouds

We're Hiring!WebsiteSlackNewsletterForumMeetupsTwitter

The Event Gateway combines both API Gateway and Pub/Sub functionality into a single event-driven experience. It's dataflow for event-driven, serverless architectures. It routes Events (data) to Functions (serverless compute). Everything it cares about is an event! Even calling a function. It makes it easy to share events across different systems, teams and organizations!

Use the Event Gateway right now, by running the Event Gateway Getting Started Application with the Serverless Framework.

Features:

  • Platform agnostic - All your cloud services are now compatible with one another: share cross-cloud functions and events with AWS Lambda, Microsoft Azure, IBM Cloud and Google Cloud Platform.
  • Send events from any cloud - Data streams in your application become events. Centralize events from any cloud provider to get a bird’s eye view of all the data flowing through your cloud.
  • React to cross-cloud events - You aren’t locked in to events and functions being on the same provider: Any event, on any cloud, can trigger any function. Set events and functions up like dominoes and watch them fall.
  • First-class support for CloudEvents - Emit and react to events in CloudEvents standard.
  • Expose events to your team - Share events and functions to other parts of the application. Your teammates can find them and utilize them in their own services.
  • Extendable through middleware - Perform data transforms, authorizations, serializations, and other custom computes straight from the Event Gateway.

The Event Gateway is a L7 proxy and realtime dataflow engine, intended for use with Functions-as-a-Service on AWS, Azure, Google & IBM.

The project is under heavy development. The APIs will continue to change until we release a 1.0.0 version. It's not yet ready for production applications.

Build Status

Event Gateway - Build event-driven integrations with lambda, cloud functions, kubernetes

Contents

  1. Quick Start
  2. Running the Event Gateway
  3. Motivation
  4. Components
    1. Event Registry
    2. Function Discovery
    3. Subscriptions
    4. Spaces
  5. CloudEvents Support
  6. SDKs
  7. Versioning
  8. FAQ
  9. Background
  10. Community

Reference

  1. API
  2. Event Types
  3. Subscription Types
  4. Architecture
  5. Clustering
  6. System Events and Plugin System
  7. System Metrics
  8. Reliability Guarantees

Quick Start

Getting Started

Looking for an example to get started? The easiest way to use the Event Gateway is with the serverless-event-gateway-plugin with the Serverless Framework. Check out the Getting Started Example to deploy your first service to the Event Gateway.

Running the Event Gateway

Hosted version

If you don't want to run the Event Gateway yourself, you can use the hosted version provided by the Serverless team. Sign up here!

via Docker

There is an official Docker image.

docker run -p 4000:4000 -p 4001:4001 serverless/event-gateway --dev

Binary

On macOS or Linux run the following to download the binary:

curl -sfL https://raw.githubusercontent.com/serverless/event-gateway/master/install.sh | sh

On Windows download binary.

Then run the binary in development mode with:

$ event-gateway --dev

Kubernetes

The repo contains helm charts for a quick deploy to an existing cluster using native nginx Ingress. To deploy a development cluster you can follow the minikube instructions.


If you want more detailed information on running and developing with the Event Gateway, please check Running Locally and Developing guides.

Motivation

  • It is cumbersome to plug things into each other. This should be easy! Why do I need to set up a queue system to keep track of new user registrations or failed logins?
  • Introspection is terrible. There is no performant way to emit logs and metrics from a function. How do I know a new piece of code is actually working? How do I feed metrics to my existing monitoring system? How do I plug this function into to my existing analytics system?
  • Using new functions is risky without the ability to incrementally deploy them.
  • The AWS API Gateway is frequently cited as a performance and cost-prohibitive factor for using AWS Lambda.

Components

Event Registry

Event Registry is a single source of truth about events occuring in the space. Every event emitted to a space has to have event type registered beforehand. Event Registry also provides a way to authorize incoming events. Please check Event Types reference for more information.

Function Discovery

Discover and call serverless functions from anything that can reach the Event Gateway. Function Discovery supports the following function types:

  • FaaS functions (AWS Lambda, Google Cloud Functions, Azure Functions, IBM Cloud Functions)
  • Connectors (AWS Kinesis, AWS Kinesis Firehose, AWS SQS)
  • HTTP endpoints/Webhook (e.g. POST http://example.com/function)

Function Discovery stores information about functions allowing the Event Gateway to call them as a reaction to received event.

Example: Register An AWS Lambda Function

curl example
curl --request POST \
  --url http://localhost:4001/v1/spaces/default/functions \
  --header 'content-type: application/json' \
  --data '{
    "functionId": "hello",
    "type": "awslambda",
    "provider":{
      "arn": "arn:aws:lambda:us-east-1:377024778620:function:bluegreen-dev-hello",
      "region": "us-east-1"
    }
}'
Node.js SDK example
const eventGateway = new EventGateway({ url: 'http://localhost' })
eventGateway.registerFunction({
  functionId: 'sendEmail',
  type: 'awslambda',
  provider: {
    arn: 'xxx',
    region: 'us-west-2'
  }
})

Subscriptions

Lightweight pub/sub system. Allows functions to asynchronously receive custom events. Instead of rewriting your functions every time you want to send data to another place, this can be handled entirely in configuration using the Event Gateway. This completely decouples functions from one another, reducing communication costs across teams, eliminates effort spent redeploying functions, and allows you to easily share events across functions, HTTP services, even different cloud providers. Functions may be registered as subscribers to a custom event. When an event occurs, all subscribers are called asynchronously with the event as its argument.

Creating a subscription requires providing ID of registered function, an event type, an HTTP method (POST by default), and a path (/ by default). The method and path properties defines HTTP endpoint which Events API will be listening on.

Event Gateway supports two subscription types: async and sync. Please check Subscription Types reference for more information.

Example: Subscribe to an Event

curl example
curl --request POST \
  --url http://localhost:4001/v1/spaces/default/subscriptions \
  --header 'content-type: application/json' \
  --data '{
    "type": "async",
    "eventType": "user.created",
    "functionId": "sendEmail",
    "path": "/myteam"
  }'
Node.js SDK example
const eventGateway = new EventGateway({ url: 'http://localhost' })
eventGateway.subscribe({
  type: 'async',
  eventType: 'user.created',
  functionId: 'sendEmail',
  path: '/myteam'
})

sendEmail function will be invoked for every user.created event to <Events API>/myteam endpoint.

Example: Emit an Event

curl example
curl --request POST \
  --url http://localhost:4000/ \
  --header 'content-type: application/json' \
  --data '{
    "eventType": "myapp.user.created",
    "eventID": "66dfc31d-6844-42fd-b1a7-a489a49f65f3",
    "cloudEventsVersion": "0.1",
    "source": "/myapp/services/users",
    "eventTime": "1990-12-31T23:59:60Z",
    "data": { "userID": "123" },
    "contentType": "application/json"
  }'
Node.js SDK example
const eventGateway = new EventGateway({ url: 'http://localhost' })
eventGateway.emit({
  "eventType": "myapp.user.created",
  "eventID": "66dfc31d-6844-42fd-b1a7-a489a49f65f3",
  "cloudEventsVersion": "0.1",
  "source": "/myapp/services/users",
  "eventTime": "1990-12-31T23:59:60Z",
  "data": { "userID": "123" },
  "contentType": "application/json"
})

Example: Subscribe to an http.request Event

Not all data are events that's why Event Gateway has a special, built-in http.request event type that enables subscribing to raw HTTP requests.

curl example
curl --request POST \
  --url http://localhost:4001/v1/spaces/default/subscriptions \
  --header 'content-type: application/json' \
  --data '{
    "type": "sync",
    "eventType": "http.request",
    "functionId": "listUsers",
    "method": "GET",
    "path": "/users"
  }'
Node.js SDK example
const eventGateway = new EventGateway({ url: 'http://localhost' })
eventGateway.subscribe({
  type: 'sync',
  eventType: 'http.request',
  functionId: 'listUsers',
  method: 'GET',
  path: '/users'
})

listUsers function will be invoked for every HTTP GET request to <Events API>/users endpoint.

Spaces

One additional concept in the Event Gateway are Spaces. Spaces provide isolation between resources. Space is a coarse-grained sandbox in which entities (Functions and Subscriptions) can interact freely. All actions are possible within a space: publishing, subscribing and invoking.

Space is not about access control/authentication/authorization. It's only about isolation. It doesn't enforce any specific subscription path.

This is how Spaces fit different needs depending on use-case:

  • single user - single user uses default space for registering function and creating subscriptions.
  • multiple teams/departments - different teams/departments use different spaces for isolation and for hiding internal implementation and architecture.

Technically speaking Space is a mandatory field ("default" by default) on Function or Subscription object that user has to provide during function registration or subscription creation. Space is a first class concept in Config API. Config API can register function in specific space or list all functions or subscriptions from a space.

CloudEvents Support

Event Gateway has the first-class support for CloudEvents. It means few things.

First of all, if the event emitted to the Event Gateway is in CloudEvents format, the Event Gateway is able to recognize it and trigger proper subscriptions based on event type specified in the event. Event Gateway supports both Structured Content and Binary Content modes described in HTTP Transport Binding spec.

Secondly, there is a special, built-in HTTP Request Event type allowing reacting to raw HTTP requests that are not formatted according to CloudEvents spec. This event type can be especially helpful for building REST APIs.

Currently, Event Gateway supports CloudEvents v0.1 schema specification.

SDKs

Versioning

This project uses Semantic Versioning 2.0.0. We are in initial development phase right now (v0.X.Y). The public APIs should not be considered stable. Every breaking change will be listed in the release changelog.

FAQ

What The Event Gateway is NOT

  • it's not a replacement for message queues (no message ordering, currently weak durability guarantees only)
  • it's not a replacement for streaming platforms (no processing capability and consumers group)
  • it's not a replacement for existing service discovery solutions from the microservices world

Event Gateway vs FaaS Providers

The Event Gateway is NOT a FaaS platform. It integrates with existing FaaS providers (AWS Lambda, Google Cloud Functions, Azure Functions, OpenWhisk Actions). The Event Gateway enables building large serverless architectures in a unified way across different providers.

Background

SOA came along with a new set of challenges. In monolithic architectures, it was simple to call a built-in library or rarely-changing external service. In SOA it involves much more network communication which is not reliable. The main problems to solve include:

  1. Where is the service deployed? How many instances are there? Which instance is the closest to me? (service discovery)
  2. Requests to the service should be balanced between all service instances (load balancing)
  3. If a remote service call failed I want to retry it (retries)
  4. If the service instance failed I want to stop sending requests there (circuit breaking)
  5. Services are written in multiple languages, I want to communicate between them using the best language for the particular task (sidecar)
  6. Calling remote service should not require setting up new connection every time as it increases request time (persistent connections)

The following systems are solutions those problems:

The main goal of those tools is to manage the inconveniences of network communication.

Microservices Challenges & FaaS

The greatest benefit of serverless/FaaS is that it solves almost all of above problems:

  1. service discovery: I don't care! I have a function name, that's all I need.
  2. load balancing: I don't care! I know that there will be a function to handle my request (blue/green deployments still an issue though)
  3. retries: It's highly unusual that my request will not proceed as function instances are ephemeral and failing function is immediately replaced with a new instance. If it happens I can easily send another request. In case of failure, it's easy to understand what is the cause.
  4. circuit breaking: Functions are ephemeral and auto-scaled, low possibility of flooding/DoS & cascading failures.
  5. sidecar: calling function is as simple as calling method from cloud provider SDK.
  6. in FaaS setting up persistent connection between two functions defeats the purpose as functions instances are ephemeral.

Tools like Envoy/Linkerd solve different domain of technical problems that doesn't occur in serverless space. They have a lot of features that are unnecessary in the context of serverless computing.

Service Discovery in FaaS = Function Discovery

Service discovery problems may be relevant to serverless architectures, especially when we have a multi-cloud setup or we want to call a serverless function from a legacy system (microservices, etc...). There is a need for some proxy that will know where the function is actually deployed and have retry logic built-in. Mapping from function name to serverless function calling metadata is a different problem from tracking the availability of a changing number of service instances. That's why there is a room for new tools that solves function discovery problem rather than the service discovery problem. Those problems are fundamentally different.

More Repositories

1

serverless

⚡ Serverless Framework – Use AWS Lambda and other managed cloud services to build apps that auto-scale, cost nothing when idle, and boast radically low maintenance.
JavaScript
46,101
star
2

examples

Serverless Examples – A collection of boilerplates and examples of serverless architectures built with the Serverless Framework on AWS Lambda, Microsoft Azure, Google Cloud Functions, and more.
JavaScript
11,353
star
3

serverless-graphql

Serverless GraphQL Examples for AWS AppSync and Apollo
JavaScript
2,720
star
4

components

The Serverless Framework's new infrastructure provisioning technology — Build, compose, & deploy serverless apps in seconds...
JavaScript
2,306
star
5

serverless-python-requirements

⚡️🐍📦 Serverless plugin to bundle Python packages
JavaScript
1,108
star
6

plugins

Serverless Plugins – Extend the Serverless Framework with these community driven plugins –
JavaScript
970
star
7

aws-ai-stack

AWS AI Stack – A ready-to-use, full-stack boilerplate project for building serverless AI applications on AWS
JavaScript
911
star
8

serverless-graphql-blog

A Serverless Blog leveraging GraphQL to offer a REST API with only 1 endpoint using Serverless v0.5
JavaScript
793
star
9

serverless-plugin-typescript

Serverless plugin for zero-config Typescript support
TypeScript
776
star
10

github-action

⚡:octocat: A Github Action for deploying with the Serverless Framework
Dockerfile
642
star
11

scope

🔭 Scope - Create a birdeye's view of your Github project and embed on your site
JavaScript
456
star
12

guide

Serverless Guide - An open-source definitive guide to serverless architectures.
Shell
439
star
13

serverless-kubeless

This plugin enables support for Kubeless within the Serverless Framework.
JavaScript
302
star
14

serverless-google-cloudfunctions

Serverless Google Cloud Functions Plugin – Adds Google Cloud Functions support to the Serverless Framework
JavaScript
272
star
15

serverless-azure-functions

Serverless Azure Functions Plugin – Add Azure Functions support to the Serverless Framework
TypeScript
266
star
16

post-scheduler

Schedule posts & content updates for static websites (Jekyll, Hugo, Gatsby, Phenomic etc)
JavaScript
191
star
17

serverless-starter

A boilerplate for new Serverless Projects
JavaScript
190
star
18

blog

serverless.com/blog – Posts from the Serverless community & core team. Contributions welcome!
JavaScript
183
star
19

serverless-client-s3

A plugin to deploy front-end assets to S3 via the Serverless Framework
JavaScript
171
star
20

serverless-websockets-plugin

Websocket support for Serverless Framework on AWS
JavaScript
149
star
21

serverless-openwhisk

Adds Apache OpenWhisk support to the Serverless Framework!
JavaScript
143
star
22

typescript

TypeScript definitions for Serverless Framework service configuration
TypeScript
140
star
23

serverless-slackbot

[Deprecated] A Serverless Module to create your own SlackBot without servers/websockets via Slash Commands
JavaScript
135
star
24

cloud

Serverless Cloud makes building, deploying, and managing serverless applications easier and more accessible to everyone.
HTML
112
star
25

compose

Orchestrate Serverless Framework in monorepos
JavaScript
109
star
26

event-gateway-example

JavaScript
104
star
27

serverless-optimizer-plugin

Serverless Optimizer Plugin: Optimizers for reducing Lambda file sizes and improving their performance -
JavaScript
102
star
28

enterprise

Documentation for the Serverless Framework Enterprise Edition –
95
star
29

multicloud

The serverless @multicloud library provides an easy way to write your serverless handlers 1 time and deploy them to multiple cloud providers include Azure & AWS.
TypeScript
90
star
30

aws-event-mocks

JavaScript
83
star
31

emulator

Serverless Emulator which lets you run serverless functions locally
JavaScript
78
star
32

serverless-local-schedule

⚡️🗺️⏰ Schedule AWS CloudWatch Event based invocations in local time(with DST support!)
JavaScript
72
star
33

event-mocks

TypeScript
72
star
34

fdk

This library is deprecated. Please use https://github.com/serverless/event-gateway-sdk instead.
JavaScript
69
star
35

serverless-open-runtime

WIP - An extensible, community-driven, open-runtime for serverless compute
Go
68
star
36

serverless-runtime-babel

Babel runtime for v.0.5 of the Serverless Framework
JavaScript
68
star
37

forms-service

Serverless Forms Service to collect form data with Admin UI
JavaScript
66
star
38

serverless-secrets-plugin

JavaScript
66
star
39

serverless-golang

Serverless Template for Golang
Go
64
star
40

serverless-tencent

⚡️ 🐧 Serverless Tencent CLI 及中文讨论社区
JavaScript
63
star
41

serverless-slack

A Serverless Module featuring pre-written Slack functions from authorization to slash commands!
JavaScript
49
star
42

dashboard-plugin

The Serverless Framework Dashboard plugin
JavaScript
49
star
43

event-gateway-getting-started

Walkthrough application for using the Event Gateway. -- https://www.serverless.com
JavaScript
48
star
44

workshop

A complete full-stack application and walkthrough for learning the features of the Serverless Framework.
CSS
45
star
45

desktop

A native GUI application that makes it easy to explore and test Serverless Framework applications built on AWS Lambda.
45
star
46

serverless-swagger-plugin

JavaScript
44
star
47

serverless-meta-sync

Secure syncing of serverless project meta data across teams
JavaScript
44
star
48

event-gateway-sdk

Event Gateway JavaScript SDK
JavaScript
43
star
49

safeguards-plugin

Serverless Framework Plugin to enforce safeguard policies
JavaScript
33
star
50

serverless-graphql-relay

Serverless GraphQL Boilerplate using Relay – Ready to be deployed to production within minutes …
JavaScript
32
star
51

utils

General serverless utilities
JavaScript
29
star
52

serverless-event-gateway-plugin

Event Gateway plugin for Serverless Framework
JavaScript
28
star
53

eslint-config

Common ESLint & Prettier config for Serverless projects
JavaScript
27
star
54

serverless-knative

Serverless Knative Provider Plugin – Adds Knative to the Serverless Framework
JavaScript
25
star
55

serverless-plugin-boilerplate

A Starter Project to help you build Plugins for the Serverless Framework -
JavaScript
24
star
56

dashboard

JavaScript
24
star
57

fullstack-course

The entire fullstack application course as seen on serverless.com/learn
JavaScript
24
star
58

serverless-babel-plugin

A Serverless plugin to compile your JavaScript code with Babel before deployment
JavaScript
23
star
59

serverless-plugin-log-retention

Control the retention of your serverless function's cloudwatch logs.
JavaScript
20
star
60

cloud-computing-conferences

A curated list of all the best cloud computing conferences happening in 2019! Check here to find a serverless or cloud event happening near you.
18
star
61

event-gateway-workshop

Learn what the Event Gateway is, how it works and build your first event-driven multi-cloud application!
JavaScript
18
star
62

fdk-tmp

The Serverless Function Development Kit (FDK)
JavaScript
18
star
63

aws-sdk-extra

The AWS SDK + a handful of extra convenience methods.
JavaScript
18
star
64

platform-sdk

Serverless Platform SDK
JavaScript
17
star
65

meetups

Want to start a Serverless usergroup? We can help you get started and be an official Serverless Usergroup. Join us to be part of the family of many Serverless Usergroups across the world.
17
star
66

boilerplate-googlecloudfunctions-nodejs

A Serverless Framework Boilerplate for Google Cloud Functions support in Node.js
JavaScript
15
star
67

cli

Serverless Components CLI
JavaScript
14
star
68

serverless-helpers-py

Python
12
star
69

tutorial

A tutorial repo with multiple projects designed to help teach users
JavaScript
11
star
70

serverless-helpers-js

Serverless Helpers Node.Js: An NPM module that provides helper functions for Serverless Modules written in Node.js -
JavaScript
11
star
71

template

Compose & provision a collection of Serverless Components
JavaScript
10
star
72

template-package

Repository template for serverless packages
JavaScript
9
star
73

serverlessconf-workshop

JavaScript
9
star
74

serverless-search-engine

Part of the Serverless Live series where we build a very simplistic search engine and spider
JavaScript
9
star
75

artwork

Official design elements of Serverless Inc. and its projects
8
star
76

extensions

Use / make / monetize developer experiences.
JavaScript
8
star
77

event-gateway-connector

Serverless Event Gateway Connector Framework
Go
7
star
78

raffleapp

A serverless raffle app
JavaScript
7
star
79

netlify-landing-page

Components Landing page demo
CSS
7
star
80

compose-example

JavaScript
6
star
81

demo-todo

An example serverless-todo app
JavaScript
5
star
82

serverless-raffle

JavaScript
5
star
83

enterprise-template

JavaScript
5
star
84

workshops

Companion repo for workshops with instructions and code examples
JavaScript
5
star
85

sls-action

GitHub action for Serverless CLI
TypeScript
5
star
86

test

Test setup and utilities for serverless projects
JavaScript
4
star
87

compose-website-example

JavaScript
4
star
88

console

4
star
89

cli-design

Repository to discuss Serverless Framework v3 redesign
HTML
4
star
90

event-gateway-tracer

JavaScript
3
star
91

core

Serverless Components Core
JavaScript
3
star
92

status

The Serverless Status Page
JavaScript
3
star
93

partner-examples

JavaScript
2
star
94

components-core

WIP
TypeScript
2
star
95

azure-build-task

A Serverless build task for Azure Dev Ops
TypeScript
1
star
96

sfe-nodejs-service

JavaScript
1
star
97

inquirer

inquirer with enforced serverless theme
JavaScript
1
star
98

template-getting-started-node-js

Application templates used by the Serverless Platform
1
star
99

serverless-cloud-gitpod

Starter repository for running Serverless Cloud on GitPod
1
star
100

user-testing

Tests of product concepts
JavaScript
1
star