Skip to content

Commit c5dea47

Browse files
committed
docs(partials): add info about using a parital with custom plugin
1 parent 2b6970b commit c5dea47

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

app/_src/gateway/kong-enterprise/partials.md

+41
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Partials address this issue by allowing you to extract shared configurations int
1515
- **`redis-ce`**: Stores common Redis configurations for plugins available in {{site.ce_product_name}}.
1616
- **`redis-ee`**: Stores common Redis configurations for plugins available only in {{site.ee_product_name}}.
1717

18+
{:.note}
19+
> An easy way to determine the required Redis configuration is by examining the fields in use. Redis CE has a shorter and simpler configuration, whereas Redis EE provides options for configuring Redis Sentinel or Redis Cluster for connection.
1820
1921
## Creating a Partial
2022

@@ -113,6 +115,45 @@ Before deleting a Partial, ensure all linked plugins are unlinked. Then, delete
113115
curl -i -X DELETE http://localhost:8001/partials/{PARTIAL-ID}
114116
```
115117

118+
## Custom Plugins
119+
120+
Users can leverage the Partials feature in their custom plugins by adjusting the plugin schema.
121+
To make custom plugins compatible with Partials, add the `supported_partials` key to the schema and specify
122+
the appropriate Partial type. If the Redis configuration in use is of the {{site.ce_product_name}} type,
123+
use `redis-ce`; otherwise, use `redis-ee`.
124+
125+
Below is an example schema for a custom plugin utilizing a Partial:
126+
127+
```lua
128+
{
129+
name = "custom-plugin-with-redis",
130+
supported_partials = {
131+
["redis-ee"] = { "config.redis" },
132+
},
133+
fields = {
134+
{
135+
config = {
136+
type = "record",
137+
fields = {
138+
{ some_other_config_key = { type = "string", required = true }},
139+
{ redis = redis.config_schema }
140+
},
141+
},
142+
},
143+
},
144+
}
145+
```
146+
147+
{:.warning} > **Using DAO in custom plugins**
148+
> Be aware that when using a Partial, the configuration belonging to the Partial is no longer stored alongside
149+
> the plugin. If your code relies on Kong's dao and expects entities to contain Redis information,
150+
> this data will not be retrieved when using `kong.db.plugins:select(plugin_id)`.
151+
> Such a call will only fetch data stored in the plugin itself.
152+
>
153+
> To include the Partial's data within the plugin configuration, pass a special option parameter,
154+
> such as: `kong.db.plugins:select(plugin_id, { expand_partials = true })`.
155+
156+
116157
## Detailed API
117158

118159
For more information about Partial configurations and usage, see the [API spec](/gateway/api/admin-ee/latest/#/partials/listPartials).

0 commit comments

Comments
 (0)