Skip to content

Commit

Permalink
update quickstart section (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianneisler authored and mthenw committed Aug 17, 2017
1 parent f0ac543 commit 069f28d
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 53 deletions.
56 changes: 3 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Azure, Google & IBM.

## Contents

1. [Installation](#installation)
1. [Quick Start](#quick-start)
1. [Motivation](#motivation)
1. [Components](#components)
Expand All @@ -35,63 +34,14 @@ Azure, Google & IBM.
1. [Clustering](#clustering)
1. [Background](#background)

## Installation

On macOS or Linux run the following:

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

On Windows download [binary](https://github.com/serverless/event-gateway/releases).

## Quick Start

_Check out [`event-gateway-examples` repo](https://github.com/serverless/event-gateway-examples) for more examples._

### Running Locally

Run `event-gateway` in `dev` mode:

```
event-gateway -dev
```

### Register a Function

Register an AWS Lambda function in the Function Discovery.

```
curl --request POST \
--url http://127.0.0.1:4001/v1/functions \
--header 'content-type: application/json' \
--data '{"functionId": "hello", "provider":{"type": "awslambda", "arn": "<Function AWS ARN>", "region": "<Region>", "accessKeyId": "<Access Key ID>", "secretAccessKey": "<Secret Access Key>"}}'
```

### Subscribe to an Event

Once the function is register you can subscribe it to you custom event.
The easiest way to get started with the event-gateway is using the [Serverless framework](https://serverless.com). The framework is setup to automatically download and install the event-gateway during development of a serverless service.

```
curl --request POST \
--url http://127.0.0.1:4001/v1/subscriptions \
--header 'content-type: application/json' \
--data '{"functionId": "hello", "event": "pageVisited"}'
```

### Emit an Event

An event can be emitted using [Events API](#events-api).

```
curl --request POST \
--url http://127.0.0.1:4000/ \
--header 'content-type: application/json' \
--header 'event: pageVisited' \
--data '{"userId": "123"}'
```
_Check out [`event-gateway-example` repo](https://github.com/serverless/event-gateway-example) for a walkthrough of using the event-gateway in local development._

After emitting the event subscribed function is called asynchronously.
If you want to install and develop with the event-gateway without the framework, [instructions can be found here](./docs/developing.md).

## Motivation

Expand Down
56 changes: 56 additions & 0 deletions docs/developing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Developing

## Installation

On macOS or Linux run the following:

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

On Windows download [binary](https://github.com/serverless/event-gateway/releases).


## Running Locally

Run `event-gateway` in `dev` mode:

```
event-gateway -dev
```

### Register a Function

Register an AWS Lambda function in the Function Discovery.

```
curl --request POST \
--url http://127.0.0.1:4001/v1/functions \
--header 'content-type: application/json' \
--data '{"functionId": "hello", "provider":{"type": "awslambda", "arn": "<Function AWS ARN>", "region": "<Region>", "accessKeyId": "<Access Key ID>", "secretAccessKey": "<Secret Access Key>"}}'
```

### Subscribe to an Event

Once the function is register you can subscribe it to you custom event.

```
curl --request POST \
--url http://127.0.0.1:4001/v1/subscriptions \
--header 'content-type: application/json' \
--data '{"functionId": "hello", "event": "pageVisited"}'
```

### Emit an Event

An event can be emitted using [Events API](#events-api).

```
curl --request POST \
--url http://127.0.0.1:4000/ \
--header 'content-type: application/json' \
--header 'event: pageVisited' \
--data '{"userId": "123"}'
```

After emitting the event subscribed function is called asynchronously.

0 comments on commit 069f28d

Please sign in to comment.