Godspeed Plugins are the way to extend the core godspeed framework. Currently we support adding Event Source and Data Source as plugin.
A brief description of how we write new plug-in in godspeed framework.
- Begin by understanding the folder
structure
.
.
├── src
├── datasources
│ ├── types
│ | └── plugin.ts
| |
│ └── plugin.yaml
│
├── events
| |
│ └── helloworld.yaml
|
├── eventsources
│ ├── types
│ | └── plugin.ts
| |
│ └── plugin.yaml
|
└── functions
|
└── helloworld.yaml
Any kind of entity which provides read and write mechanism for data is considered a datasource. For example, an API, a SQL or NoSQL datastore which includes RDBMS or mongodb,postgresql, key value stores, document stores etc. The settings for each datasource lies in src/datasources directory.
-
Inside the
datasources
directory, create aYAML
file with a specific name. In this YAML file, ensure you specify atype
field, and there must be a correspondingTypeScript
file in thetypes
directory that shares the same name as thetype
you defined. -
Look for the
npm package
you wish to integrate with Godspeed framework. -
In your TypeScript file, use an import statement to bring in
GSDataSource
from the@godspeedsystems/core
package. Then, create a class that inherits fromGSDataSource
. -
Afterward, you can access the methods provided by
GSDataSource
. Initialize your client by calling theinitClient()
function. -
Once your client is initialized, you can execute its methods using the
execute
function.
type: axios
base_url: http://localhost:5440
import { GSContext, GSDataSource, GSStatus, PlainObject } from "@godspeedsystems/core";
class DataSource extends GSDataSource {
protected async initClient(): Promise<object> {
// initialize client here
}
async execute(ctx: GSContext, args: PlainObject): Promise<any> {
// Execute methods here
}
}
"http.get./helloworld":
fn:axios_workflow :
body:
type: object
responses:
200:
application/json:
id: helloworld
tasks:
id: fist_task
fn: datasource.axios./helloworld
args:
An event source is any entity or technology responsible for generating events or notifications when specific events or conditions occur. These events are consumed by event handlers or processors for real-time or near-real-time responses. Event sources can include Message Brokers, Webhooks etc.The settings for each datasource lies in src/eventsources directory.
-
Inside the
eventsources
directory, create aYAML
file with a specific name. In this YAML file, ensure you specify atype
field, and there must be a correspondingTypeScript
file in thetypes
directory that shares the same name as thetype
you defined. -
Look for the
npm package
you wish to integrate with Godspeed framework. -
In your TypeScript file, use an import statement to bring in
GSEventSource
from the@godspeedsystems/core
package. Then, create a class that inherits fromGSEventSource
. -
Afterward, you can access the methods provided by
GSEventSource
. Initialize your client by calling theinitClient()
function. -
Once your client is initialized, you can execute its subscription using the
subscribeToEvent
function.
type: cron
import {GSEventSource, GSCloudEvent, GSStatus, GSActor,PlainObject } from "@godspeedsystems/core";
import cron from "node-cron";
export default class EventSource extends GSEventSource {
protected initClient(): Promise<PlainObject> {
// initialize client here
}
subscribeToEvent( eventKey: string,eventConfig: PlainObject, processEvent: (event: GSCloudEvent, eventConfig: PlainObject) => Promise<GSStatus> ): Promise<void> {
// write subscribe method here
}
}
# event for Shedule a task for evrey minute.
cron.* * * * *.Asia/Kolkata:
fn: every_minute
For cron expressions https://crontab.cronhub.io/
summary: this workflow will be running every minute
tasks:
- id: print
description: print for every minute
fn: com.gs.return
args:
data: HELLO from CRON
Any kind of entity which provides read and write mechanism for data and acts as an entity responsible for generating events or notifications when specific events or conditions occur. These events are consumed by event handlers.
-
Look for the
npm package
you wish to integrate with Godspeed framework. -
Inside the
DataSources
directory, create aYAML
file with a specific name. In this YAML file, ensure you specify atype
field, and there must be a correspondingTypeScript
file in thetypes
directory that shares the same name as thetype
you defined. -
In your TypeScript file, use an import statement to bring in
GSDataSource
from the@godspeedsystems/core
package. Then, create a class that inherits fromGSDataSource
. -
Afterward, you can access the methods provided by
GSDataSource
. Initialize your client by calling theinitClient()
function. -
Once your client is initialized, you can execute its methods using the
execute
function.
type: Kafka
clientId: "kafka_proj"
brokers: ["kafka:9092"]
import { GSContext, GSDataSource, PlainObject } from "@godspeedsystems/core";
import { Kafka } from "kafkajs"; // importing required npm module.
export default class DataSource extends GSDataSource {
protected async initClient(): Promise<PlainObject> {
// initialize your client.
}
async execute(ctx: GSContext, args: PlainObject): Promise<any> {
try {
// execute methods here
} catch (error) {
throw error;
}
}
}
'http.post./kafka-pub':
fn: kafka-publish
body:
content:
application/json:
schema:
type: object
properties:
message:
type: string
required: ['message']
responses:
200:
content:
application/json:
schema:
type: object
properties:
name:
type: string
id: kafka-publish
summary: kafka publish message
tasks:
- id: publish
fn: datasource.kafka.producer
args:
topic: "publish-producer1"
message: <% inputs.body.message%>
-
Inside the
eventsources
directory, create aYAML
file with a specific name. In this YAML file, ensure you specify atype
field, and there must be a correspondingTypeScript
file in thetypes
directory that shares the same name as thetype
you defined. -
In your TypeScript file, use an import statement to bring in
GSEventSource
from the@godspeedsystems/core
package. Then, create a class that inherits fromGSEventSource
. -
Your client is initialized already in Datasource so you can execute its subscription using the
subscribeToEvent
function.
type: kafka
groupId: "kafka_proj"
import { GSCloudEvent, GSStatus, GSActor, GSDataSourceAsEventSource, PlainObject} from "@godspeedsystems/core";
export default class DataSourceAsEventSource extends GSDataSourceAsEventSource { async subscribeToEvent(eventKey: string, eventConfig: PlainObject, processEvent: (event: GSCloudEvent, eventConfig: PlainObject) => Promise<GSStatus>): Promise<void> {
// Write your Subscribe method here.
}
}
kafka.publish-producer1.kafka_proj:
id: kafka__consumer
fn: kafka_consume
body:
description: The body of the query
content:
application/json:
schema:
type: string
id: kafka-conumer
summary: consumer
tasks:
- id: set_con
fn: com.gs.return
args: <% inputs %>
No | Plugin Name | Type | npm package link | Documentation | Maintained by |
---|---|---|---|---|---|
1 | Express | Eventsource | npm | readme | Godspeed |
2 | Prisma | Datasource | npm | readme | Godspeed |
3 | Apache Kafka | DS & ES | npm | readme | Godspeed |
4 | CRON Eventsource | Eventsource | npm | readme | Godspeed |
5 | MongoDB | ||||
6 | Cassandra | ||||
7 | Redis | ||||
8 | Elasticsearch | ||||
9 | Splunk | ||||
10 | MySQL | ||||
11 | RabbitMQ | ||||
12 | Amazon S3 | ||||
13 | Salesforce | ||||
14 | HubSpot | ||||
15 | MailChimp | ||||
16 | Microsoft Access | ||||
17 | SQLite | ||||
18 | DB2 (IBM Database) | ||||
19 | Neo4j | ||||
20 | CockroachDB | ||||
21 | MariaDB | ||||
22 | Google Cloud Pub/Sub | ||||
23 | RabbitMQ | ||||
24 | GraphQL | ||||
25 | gRPC | ||||
26 | JMeter | ||||
27 | JIRA Software | ||||
28 | Jenkins | ||||
29 | GitLab CI/CD | ||||
30 | Azure DevOps | ||||
31 | Heroku | ||||
32 | Vercel | ||||
33 | Netlify | ||||
34 | PostgreSQL |