Skip to content

Commit

Permalink
enhances the lines desc
Browse files Browse the repository at this point in the history
  • Loading branch information
afzal442 authored Sep 15, 2023
1 parent 04231a9 commit 571ba71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
22 changes: 11 additions & 11 deletions docs/env-vars-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ weight: 80

# Environment Variables

Glee provides a few environment variables for you to customize the experience:
Glee provides a few environment variables for you to customize the Glee application's behavior according to your specific requirements:
|Variable|Description|Example|
|---|---|---|
|GLEE_SERVER_NAMES|A comma-separated list of the servers to load on startup.|`GLEE_SERVER_NAMES=websockets,mosquitto`
|GLEE_SERVER_CERTS|A comma-separated list of `${serverName}:${pathToCertificateFile}`. These are the certificates to use when establishing the connection to the given server.|`GLEE_SERVER_CERTS=mosquitto:mosquitto.org.crt`
|GLEE_SERVER_VARIABLES|A comma-separated list of `${serverName}:${serverVariable}:${value}`. These are the values to use for each server variable.|`GLEE_SERVER_VARIABLES=websockets:namespace:public`

Configuring Glee
## Configuring Glee

Glee comes with sensible defaults so you don't have to worry about configuration. However, sometimes you may want to change the behavior or customize Glee in different ways. For that purpose, you can use the `glee.config.js` file.

## The configuration file
### The configuration file

Glee's config file is a JavaScript file that exports an async function. Something like this:

Expand Down Expand Up @@ -107,21 +107,21 @@ export default async function () {
}
```
Inside the return statement, you can specify the following options:
### Glee Core Configurations
#### Glee Core Configurations
These configurations apply to Glee itself, rather than any specific protocol.
|Field|Default|Description|
|--|--|--|
|glee.gleeDir|`.glee`|Sets the Glee directory. Your sources will be compiled here.|
|glee.lifecycleDir|`lifecycle`|Path to the directory that stores your [lifecycle events](./lifecycle-events.md).|
|glee.functionsDir|`functions`| Path to the directory that stores your [functions](./functions.md).|
|glee.asyncapiFilePath|`asyncapi.(yaml \| yml \| json)`| Path to your AsyncAPI file. |
### Generating Documentation
#### Generating Documentation
|Field|Description|
|--|--|
|docs.enabled|This flag enables/disables the docs generation functionality.
|docs.folder|The dedicated folder you want your generated docs to reside.
|docs.template|The AsyncAPI template you wanna use for generating your documentation.
### Websocket Server
#### Websocket Server
|Field|Description|
|--|--|
|ws.server|Websocket server-specific configurations|
Expand All @@ -131,21 +131,21 @@ These configurations apply to Glee itself, rather than any specific protocol.
|ws.server.port| The port to use when binding the WebSocket server. This is useful when your server is behind a proxy and the port exposed for consumption is not the same as the port your application should be bound to. Defaults to the port specified in the selected AsyncAPI server.|
|ws.client.auth| Authentication variables for client|
|ws.client.auth.token| HTTP Authentication header|
### Cluster
#### Cluster
|Field|Description|
|--|--|
|cluster.adapter| The Glee cluster adapter to use for communication between instances. Defaults to Redis Pub/Sub ("redis"). Can be a reference to a custom adapter.|
|cluster.name|The name of the cluster. Defaults to "cluster".|
|cluster.url|The url of the server to be used by the adapter. In case of "redis" adapter, it's the url of the Redis server.|
### MQTT
#### MQTT
|Field|Description|
|---|---|
|mqtt.auth| MQTT authentication configuration|
|mqtt.auth.cert| Client certificate
|mqtt.auth.clientId| MQTT client Id for authentication
|mqtt.auth.username| username parameter
|mqtt.auth.password| password parameter
### Kafka
#### Kafka
|Field|Description|
|---|---|
|kafka.auth| Kafka authentication configuration|
Expand All @@ -155,7 +155,7 @@ These configurations apply to Glee itself, rather than any specific protocol.
|kafka.auth.rejectUnauthorized | Boolean flag for accepting the valid SSL certificates
|kafka.auth.username| The username to use during authentication.
|kafka.auth.password| The password to use during authentication.
### HTTP Server
#### HTTP Server
|Field|Description|
|--|--|
|http.server|HTTP server-specific configurations|
Expand All @@ -166,7 +166,7 @@ These configurations apply to Glee itself, rather than any specific protocol.
|http.client.auth.token| HTTP Authentication header|
|http.client.query| Query object for the client to send|
|http.client.body| Body object for the client to send
### Auth Config
#### Auth Config
Most clients like `ws`,`kafka`, and `mqtt` have auth fields that are used for passing auth parameters. All these configurations can be an object or a function that returns the specific object defined by each protocol.
```js
Expand Down
5 changes: 2 additions & 3 deletions docs/function-lifecycle-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default async function (event) {
// Your business logic here...
}
```

Functions take a single argument, which is the event received from a broker or a client, depending which kind of API you're building. The `event` argument has the following shape:
|Attribute|Description|
|----|----|
Expand All @@ -30,6 +31,7 @@ export default async function (event) {
}
}
```

|Attribute|Type|Description|
|---|---|---|
|send|array<[OutboundMessage](#anatomy-of-an-outbound-message)>|A list of outbound messages to send when the processing of the inbound event has finished. All clients subscribed to the given channel/topic will receive the message.
Expand Down Expand Up @@ -59,7 +61,6 @@ Glee maps the `onHello` operation to the `functions/onHello.js` file.
Glee lets you bind incoming messages to functions. However, sometimes we need to be proactive and be the first ones to send a message, not necessarily as a reaction to another message. Use cases can be very diverse: from sending a message to announce our client is connected to sending a message every few seconds or minutes.

To subscribe to a lifecycle event, create a file under the `lifecycle` directory. It must have the following shape:

```js
export default async function ({
glee,
Expand Down Expand Up @@ -98,15 +99,13 @@ All of them take a single argument which contains information about the event:
## Restricting the lifecycle event

In some cases it's useful to restrict the lifecycle event to a specific server or set of servers. To do that, add a line like the following to your lifecycle file:

```js
export const servers = ['mosquitto']
```

The above example makes Glee fire the lifecycle event only if it's coming from the `mosquitto` server.

Additionally, you may want to restrict the lifecycle event by channel/topic. To do that, add a line like the following to your lifecycle file:

```js
export const channels = ['user/signedup']
```
Expand Down

0 comments on commit 571ba71

Please sign in to comment.