Skip to content

Commit

Permalink
25 messages limit (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
if0s authored Jan 29, 2024
1 parent 0939dae commit 847c460
Show file tree
Hide file tree
Showing 10 changed files with 6,421 additions and 9,240 deletions.
132 changes: 116 additions & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,127 @@
version: 2
version: 2.1
parameters:
node-version:
type: string
default: "20.11.0"
orbs:
node: circleci/[email protected]
slack: circleci/[email protected]
commands:
notify_on_failure:
steps:
- slack/notify:
event: fail
custom: |
{
"blocks": [
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": ":red_circle: *$CIRCLE_PROJECT_REPONAME*:*$CIRCLE_TAG* build failed"
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Job"
},
"url": "${CIRCLE_BUILD_URL}"
}
]
}
]
}
notify_on_pass:
steps:
- slack/notify:
event: pass
custom: |
{
"blocks": [
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": ":tada: *$CIRCLE_PROJECT_REPONAME*:*$CIRCLE_TAG* was successfully built and published"
}
]
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View Job"
},
"url": "${CIRCLE_BUILD_URL}"
}
]
}
]
}
jobs:
test:
docker:
- image: circleci/node:14-stretch
- image: cimg/node:20.11.0
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- node/install:
node-version: << pipeline.parameters.node-version >>
- node/install-packages:
cache-path: ./node_modules
override-ci-command: npm install
- run:
name: Audit Dependencies
command: npm audit --audit-level=critical
- run:
name: Installing Dependencies
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
command: npm audit --production --audit-level=high
- run:
name: Running Mocha Unit Tests
name: Running Mocha Tests
command: npm test
build:
docker:
- image: cimg/node:20.11.0
user: root
steps:
- checkout
- node/install:
node-version: << pipeline.parameters.node-version >>
- setup_remote_docker:
version: 19.03.13
docker_layer_caching: true
# build and push Docker image
- run:
name: Install component-build-helper lib
command: npm install -g @elastic.io/component-build-helper
- run:
name: Build and publish docker image
command: build_component_docker
- notify_on_failure
- notify_on_pass
workflows:
version: 2
build_and_test:
test:
jobs:
- test:
name: "Running tests"
filters:
tags:
ignore: /.*/
publish_release:
jobs:
- test
- build:
name: "Build and publish docker image"
context:
- componentspusher
filters:
branches:
ignore: /.*/
tags:
only: /^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
extends: 'airbnb-base',
parser: 'babel-eslint',
env: {
mocha: true,
},
Expand All @@ -8,12 +9,13 @@ module.exports = {
'no-useless-constructor': 'off',
'max-classes-per-file': 'off',
'class-methods-use-this': 'off',
'no-unused-vars': ['error', { args: 'none'}],
'no-unused-vars': ['error', { args: 'none' }],
'no-plusplus': 'off',
'no-await-in-loop': 'off',
'guard-for-in': 'off',
'no-restricted-syntax': ['error', 'LabeledStatement', 'WithStatement'],
'import/prefer-default-export': 'off',
'import/extensions': 'off',
'object-curly-newline': 0,
},
};
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.8.0 (January 29, 2024)
* Added new `Subscribe` trigger (old one set as deprecated)
* Bump dependencies

# 1.7.3 (July 23, 2021)
* Fix bug with not-awaited emits and endless cycle problem
* Bump dependencies
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [Credentials](#credentials)
* [Triggers](#triggers)
* [Subscribe](#subscribe)
* [Deprecated triggers](#deprecated-triggers)
* [Actions](#actions)
* [Publish](#publish)
* [Additional info](#additional-info)
Expand Down Expand Up @@ -50,8 +51,38 @@ The Subscribe trigger receives a message from a Topic, emits it, and sends an ac

#### Configuration

- `Select topic to subscribe` - (dropdown, required): Select one of the available topics from the list

#### Input Metadata

None.

#### Output Metadata

* **data** - (object or string, required): Data of the message, the component will try to parse it as JSON object, if fails - result will be plain text
* **attributes** - (object, optional): Attributes for this message - a list of `"key": value` pairs
* **id** - (string, required): ID of this message, assigned by the server when the message is published
* **publishTime** - (string, required): The time at which the message was published to Google Pub-Sub server
* **received** - (string, required): The time at which the message was read by the component

#### Limitations:
* If you use ordinary flow (`real-time` not enabled) after flow starts you will need to run it once (make execution) to create a subscription in Google Pub-Sub

### Deprecated triggers

<details>
<summary>Subscribe</summary>

### Subscribe

The Subscribe trigger receives a message from a Topic, emits it, and sends an acknowledgment to Pub/Sub.

#### Configuration

- `Topic Name` - (required field) fully-qualified topic resource name string, e.g. `projects/<project_id>/topics/<topic_name>`

</details>

## Actions

### Publish
Expand Down
44 changes: 36 additions & 8 deletions component.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Google Pubsub",
"description": "Interact with Google Pub-Sub API",
"buildType": "docker",
"version": "1.7.3",
"version": "1.8.0",
"env": [
"GOOGLE_APP_ID",
"GOOGLE_APP_SECRET"
Expand Down Expand Up @@ -30,7 +30,7 @@
"actions": {
"pub": {
"title": "Publish",
"note":"The Publish action retrieves message body from a previous step and sends a message to a Topic while remaining unaware of any existing subscriptions.",
"note": "The Publish action retrieves message body from a previous step and sends a message to a Topic while remaining unaware of any existing subscriptions.",
"main": "./lib/actions/pub.js",
"fields": {
"topicName": {
Expand All @@ -55,29 +55,57 @@
},
"triggers": {
"subscribe": {
"title": "Subscribe",
"note":"The Subscribe trigger receives a message from a Topic, emits it, and sends an acknowledgment to Pub/Sub.",
"title": "Subscribe (deprecated)",
"note": "The Subscribe trigger receives a message from a Topic, emits it, and sends an acknowledgment to Pub/Sub.",
"main": "./lib/triggers/pull.js",
"type": "polling",
"deprecated": true,
"fields": {
"topicName": {
"label": "Topic Name",
"viewClass": "TextFieldView",
"placeholder": "projects/elasticio-test-project/topics/test",
"required": true
}
}
},
"newSubscribe": {
"title": "Subscribe",
"note": "The Subscribe trigger receives a message from a Topic, emits it, and sends an acknowledgment to Pub/Sub.",
"main": "./lib/triggers/subscribe.js",
"type": "polling",
"fields": {
"topic": {
"label": "Select topic to subscribe",
"viewClass": "SelectView",
"required": false,
"model": "getTopicsList"
}
},
"metadata": {
"out": {
"type": "object",
"properties": {
"MessageId": {
"type": "string",
"required": true
"id": {
"type": "string"
},
"attributes": {
"type": "object",
"properties": {}
},
"data": {
"type": "object",
"properties": {}
},
"publishTime": {
"type": "string"
},
"received": {
"type": "string"
}
}
}
}
}
}
}
}
Loading

0 comments on commit 847c460

Please sign in to comment.