Skip to content

Commit

Permalink
Update act docs to include async action redis configuration (#60)
Browse files Browse the repository at this point in the history
* Update act docs to include async action redis configuration
* Change wording

---------

Co-authored-by: Mostafa Moradian <mostafa@gatewayd.io>
  • Loading branch information
Hamsajj and mostafa authored Jun 3, 2024
1 parent ddb3d22 commit e3a93d3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
7 changes: 5 additions & 2 deletions using-gatewayd/Act.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ parent: Using GatewayD

# Act

Act, a core component of GatewayD, is a policy engine that supports signals, policies and actions. It is used to automate the execution of business rules. The business rules are currently written as expressions in the [Expr](https://github.com/expr-lang/expr) language, with support for external policy engines to come. The expressions are evaluated against the signals received from the plugins and the corresponding actions are executed if the policy expressions evaluate to true (boolean) or any other type recognized by the action.
Act, a core component of GatewayD, is a policy engine that supports signals, policies and actions. It enables a range of functionalities by automating the execution of business rules. The business rules are currently written as expressions in the [Expr](https://github.com/expr-lang/expr) language, with support for external policy engines to come. The expressions are evaluated against the signals received from the plugins (and possibly other sources). If the policy expressions evaluate to `true` (boolean) or any other type recognized by the corresponding action, then the action will be executed. Alternatively, Act can publish the result of policy evaluation to a Redis Pub/Sub queue in the [`Output`](https://github.com/gatewayd-io/gatewayd-plugin-sdk/blob/bc5513b395c6622b10db02b6608a972cef909e3d/act/io.go#L18-L24) format. This enables plugins and external systems to subscribe to the events published on that channel and run any arbitrary actions necessary based on the given parameters.

Previously, there were only a single signal, policy and action, called the `terminatePolicy`, which were hard-coded into the GatewayD codebase. This made it difficult to extend and customize the behavior of GatewayD. With the new Act, based on [this proposal](https://github.com/gatewayd-io/proposals/issues/5), the signals, policies and actions are pluggable and can be extended to support custom requirements. This opens up a wide range of possibilities for customizing the behavior of GatewayD to suit the needs of different use cases. For example, a policy can be written to check if the request is coming from a specific IP address, and if so, the action can be to terminate the request.

Expand Down Expand Up @@ -86,7 +86,10 @@ The `Hook` field is a map that contains the following fields:

## Actions

The action can be run in sync or async mode, and it can return a result or an error. The actions are executed if the policy expressions evaluate to true (boolean) or any other type recognized by the action. The actions have the following fields:
The action can be run in sync or async mode, and it can return a result or an error.
Async actions can be configured to be published to a Redis channel instead of running in a background goroutine.
To configure Act to publish async actions to a Redis channel, use `actionRedis` value of [general configuration](/using-gatewayd/plugins-configuration/general-configurations#Configuration parameters)
The actions are executed, or published, if the policy expressions evaluate to true (boolean) or any other type recognized by the action. The actions have the following fields:

1. `name`: The name of the action, such as `terminate`, `log`, etc.
2. `metadata`: The metadata associated with the action, such as the log message and log level.
Expand Down
Loading

0 comments on commit e3a93d3

Please sign in to comment.