Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bring eventbridge #42

Merged
merged 29 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c076325
feat: `bring eventbridge`
skorfmann Dec 22, 2023
456259d
Merge branch 'main' into eventbridge
skorfmann Dec 22, 2023
c316216
Merge branch 'main' into eventbridge
eladb Dec 30, 2023
52b9fe8
fix (#45)
MarkMcCulloh Dec 30, 2023
2cd6d10
fix(websockets): fix token usage in simulator (#46)
eladb Jan 1, 2024
aafd29b
chore(bedrock): replacing BEDROCK_DEV with isTestEnvironment (#47)
ekeren Jan 2, 2024
c65266b
feat: `bring github` (#39)
eladcon Jan 2, 2024
5c0d7b5
fix(github): mts to js files (#48)
ekeren Jan 2, 2024
2a18bad
fix(github): using interface for credentials instead of cloud.secret …
ekeren Jan 2, 2024
c18f81b
fix(github): can't compile to tf-aws, missing cloud.service (#50)
ekeren Jan 3, 2024
dfa0cb1
chore: set up GitHub releases (#51)
Chriscbr Jan 4, 2024
7ec95d7
chore: mergify fixes (#52)
Chriscbr Jan 4, 2024
ce2696d
chore: fix mergify conditions (#53)
Chriscbr Jan 4, 2024
9adcff4
chore: mergify fixing continued (#54)
Chriscbr Jan 4, 2024
6b9db75
chore: mergify fixes (#55)
Chriscbr Jan 4, 2024
0439bf9
chore: testing
Chriscbr Jan 4, 2024
e4e9ae2
fix: unit test regression (#56)
Chriscbr Jan 4, 2024
40c0f54
Merge branch 'main' into eventbridge
skorfmann Feb 29, 2024
0db1cc1
deployable version
skorfmann Feb 29, 2024
a97d641
remove accidental commit
skorfmann Feb 29, 2024
1d6e04c
Update eventbridge/platform/sim/bus.w
eladcon Mar 7, 2024
df57157
wip
eladcon Mar 7, 2024
7fbd3fa
wip
eladcon Mar 7, 2024
1861b0c
wip
eladcon Mar 7, 2024
e6b86c3
wip
eladcon Mar 7, 2024
9978071
wip
eladcon Mar 13, 2024
0a72274
wip
eladcon Mar 13, 2024
82df437
wip
eladcon Mar 13, 2024
5ff5b76
Merge branch 'main' into eventbridge
eladcon Mar 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/eventbridge-pull.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: eventbridge-pull
on:
pull_request:
paths:
- eventbridge/**
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
sparse-checkout: eventbridge
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: https://registry.npmjs.org
- name: Install winglang
run: npm i -g winglang
- name: Install dependencies
run: npm install --include=dev
working-directory: eventbridge
- name: Test
run: wing test
working-directory: eventbridge
- name: Pack
run: wing pack
working-directory: eventbridge
37 changes: 37 additions & 0 deletions .github/workflows/eventbridge-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: eventbridge-release
on:
push:
branches:
- main
paths:
- eventbridge/**
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
sparse-checkout: eventbridge
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: https://registry.npmjs.org
- name: Install winglang
run: npm i -g winglang
- name: Install dependencies
run: npm install --include=dev
working-directory: eventbridge
- name: Test
run: wing test
working-directory: eventbridge
- name: Pack
run: wing pack
working-directory: eventbridge
- name: Publish
run: npm publish --access=public --registry https://registry.npmjs.org --tag
latest *.tgz
working-directory: eventbridge
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions eventbridge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
node_modules/
21 changes: 21 additions & 0 deletions eventbridge/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Wing

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 23 additions & 0 deletions eventbridge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# eventbridge
eladcon marked this conversation as resolved.
Show resolved Hide resolved

## Prerequisites

* [winglang](https://winglang.io).

## Installation

`sh
npm i @winglibs/eventbridge
`

## Usage

`js
bring eventbridge;

let adder = new eventbridge.Adder();
`

## License

This library is licensed under the [MIT License](./LICENSE).
80 changes: 80 additions & 0 deletions eventbridge/lib.test.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
bring cloud;
bring expect;
bring util;
bring "./lib.w" as lib;
bring "./types.w" as types;

// this is the actual event bus, shouldn't be
// referenced directly, but rather through the
// EventBridge class for publishing or subscribing.
new lib.EventBridgeInstance(
eladcon marked this conversation as resolved.
Show resolved Hide resolved
name: "test",
);

class InboundGithubEvents {
pub bucket: cloud.Bucket;

new() {
let eventBridge = new lib.EventBridge();

this.bucket = new cloud.Bucket();
let counter = new cloud.Counter();

let fn = new cloud.Function(inflight (event) => {
log("subscribed event received {event}");
this.bucket.put("test-{counter.inc()}", event);
});

eventBridge.subscribeFunction("github.pull-request.created", fn, {
"detail-type": [{"prefix": "pull-request."}],
"source": ["github.com"],
});
}
}

class Environments {
new() {
let eventBridge = new lib.EventBridge();
let queue = new cloud.Queue();

eventBridge.subscribeQueue("environments.created", queue, {
"detail-type": "test",
resources: ["test"],
source: "test",
version: 0,
detail: {
"test": "test",
},
});
}
}

let github = new InboundGithubEvents();
new Environments();

// this is the client, which needs to be created
// preflight, so that the references are available
let eventBridge = new lib.EventBridge();

test "publish to eventbridge" {
eventBridge.publish(
detailType: "pull-request.created",
resources: ["test"],
source: "github.com",
version: 0,
detail: {
"test": "test",
},
);

util.waitUntil(inflight () => {
return github.bucket.exists("test-0");
}, {
timeout: 5s,
});

let published = types.Event.fromJson(github.bucket.getJson("test-0"));
expect.equal("pull-request.created", published.detailType);
expect.equal("test", published.resources.at(0));
expect.equal("github.com", published.source);
}
32 changes: 32 additions & 0 deletions eventbridge/lib.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
bring cloud;
bring "./types.w" as types;
bring "./platform/sim" as sim;

pub class EventBridgeInstance impl types.IEventBridgeInstance {
inner: types.IEventBridgeInstance;

new(props: types.EventBridgeProps) {
this.inner = new sim.EventBridgeInstance(props);
let node = std.Node.of(this);
node.hidden = true;
}
}

pub class EventBridge impl types.IEventBridge {
eladcon marked this conversation as resolved.
Show resolved Hide resolved
inner: types.IEventBridge;

new() {
this.inner = new sim.EventBridge();
}

pub inflight publish(event: types.PublishEvent): void {
this.inner.publish(event);
}

pub subscribeFunction(name: str, handler: cloud.Function, pattern: Json): void {
this.inner.subscribeFunction(name, handler, pattern);
}
pub subscribeQueue(name: str, queue: cloud.Queue, pattern: Json): void {
this.inner.subscribeQueue(name, queue, pattern);
}
}
Loading
Loading