You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/relayer/1.2.x/plugins/index.mdx
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -346,30 +346,30 @@ curl -X POST http://localhost:8080/api/v1/plugins/example-plugin/call \
346
346
347
347
```
348
348
349
-
== Response Fields
349
+
##Response Fields
350
350
351
351
-**`data`**: The value returned by your plugin's handler function (decoded from JSON when possible)
352
352
-**`metadata.logs`**: Terminal output from the plugin (console.log, console.error, etc.) when `emit_logs` is true
353
353
-**`metadata.traces`**: Messages exchanged between the plugin and the Relayer via PluginAPI when `emit_traces` is true
354
354
-**`error`**: Error message if the plugin execution failed (business errors)
355
355
356
-
== Key-Value Storage
356
+
##Key-Value Storage
357
357
358
358
The Relayer provides a built-in key-value store for plugins to maintain persistent state across invocations. This addresses the core problem of enabling persistent state management and programmatic configuration updates for plugins.
359
359
360
-
=== Why a KV store?
360
+
###Why a KV store?
361
361
362
362
- Plugins execute as isolated processes with no persistent memory
363
363
- No mechanism exists to maintain state between invocations
364
364
- Plugins requiring shared state or coordination need safe concurrency primitives
365
365
366
-
=== Configuration
366
+
###Configuration
367
367
368
368
- Reuses the same Redis URL as the Relayer via the `REDIS_URL` environment variable
369
369
- No extra configuration is required
370
370
- Keys are namespaced per plugin ID to prevent collisions
371
371
372
-
=== Usage
372
+
###Usage
373
373
374
374
Access the KV store through the `kv` property in the `PluginContext`:
375
375
@@ -394,7 +394,7 @@ export async function handler(context: PluginContext) {
394
394
395
395
```
396
396
397
-
=== Available Methods
397
+
###Available Methods
398
398
399
399
-`get<T>(key: string): Promise<T | null>`
400
400
-`set(key: string, value: unknown, opts?: ttlSec?: number ): Promise<boolean>`
@@ -406,16 +406,16 @@ export async function handler(context: PluginContext) {
406
406
407
407
Keys must match `[A-Za-z0-9:_-]1,512` and are automatically namespaced per plugin.
408
408
409
-
== Migration from Legacy Patterns
409
+
##Migration from Legacy Patterns
410
410
411
-
=== Current Status
411
+
###Current Status
412
412
413
413
- ✅ **Legacy plugins still work** - No immediate action required
414
414
- ⚠️ **Deprecation warnings** - Legacy plugins will show console warnings
415
415
- 📅 **Future removal** - The legacy `runPlugin` and two-parameter `handler(api, params)` will be removed in a future major version
416
416
- 🎯 **Recommended action** - Migrate to single-parameter `PluginContext` handler for new plugins and KV access
417
417
418
-
=== Migration Steps
418
+
###Migration Steps
419
419
420
420
If you have existing plugins using `runPlugin()` or the two-parameter handler, migration is simple:
421
421
@@ -455,7 +455,7 @@ export async function handler(context: PluginContext): Promise<any>
455
455
456
456
```
457
457
458
-
=== Step-by-Step Migration
458
+
###Step-by-Step Migration
459
459
460
460
1.**Remove the `runPlugin()` call** at the bottom of your file
461
461
2.**Rename your function to `handler`** (or create a new handler export)
@@ -464,7 +464,7 @@ export async function handler(context: PluginContext): Promise<any>
464
464
5.**Test your plugin** to ensure it works with the new pattern
465
465
6.**Update your documentation** to reflect the new pattern
466
466
467
-
=== Backwards Compatibility
467
+
###Backwards Compatibility
468
468
469
469
The relayer will automatically detect which pattern your plugin uses:
Copy file name to clipboardExpand all lines: content/relayer/plugins/index.mdx
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -346,30 +346,30 @@ curl -X POST http://localhost:8080/api/v1/plugins/example-plugin/call \
346
346
347
347
```
348
348
349
-
== Response Fields
349
+
##Response Fields
350
350
351
351
-**`data`**: The value returned by your plugin's handler function (decoded from JSON when possible)
352
352
-**`metadata.logs`**: Terminal output from the plugin (console.log, console.error, etc.) when `emit_logs` is true
353
353
-**`metadata.traces`**: Messages exchanged between the plugin and the Relayer via PluginAPI when `emit_traces` is true
354
354
-**`error`**: Error message if the plugin execution failed (business errors)
355
355
356
-
== Key-Value Storage
356
+
##Key-Value Storage
357
357
358
358
The Relayer provides a built-in key-value store for plugins to maintain persistent state across invocations. This addresses the core problem of enabling persistent state management and programmatic configuration updates for plugins.
359
359
360
-
=== Why a KV store?
360
+
###Why a KV store?
361
361
362
362
- Plugins execute as isolated processes with no persistent memory
363
363
- No mechanism exists to maintain state between invocations
364
364
- Plugins requiring shared state or coordination need safe concurrency primitives
365
365
366
-
=== Configuration
366
+
###Configuration
367
367
368
368
- Reuses the same Redis URL as the Relayer via the `REDIS_URL` environment variable
369
369
- No extra configuration is required
370
370
- Keys are namespaced per plugin ID to prevent collisions
371
371
372
-
=== Usage
372
+
###Usage
373
373
374
374
Access the KV store through the `kv` property in the `PluginContext`:
375
375
@@ -394,7 +394,7 @@ export async function handler(context: PluginContext) {
394
394
395
395
```
396
396
397
-
=== Available Methods
397
+
###Available Methods
398
398
399
399
-`get<T>(key: string): Promise<T | null>`
400
400
-`set(key: string, value: unknown, opts?: ttlSec?: number ): Promise<boolean>`
@@ -406,16 +406,16 @@ export async function handler(context: PluginContext) {
406
406
407
407
Keys must match `[A-Za-z0-9:_-]1,512` and are automatically namespaced per plugin.
408
408
409
-
== Migration from Legacy Patterns
409
+
##Migration from Legacy Patterns
410
410
411
-
=== Current Status
411
+
###Current Status
412
412
413
413
- ✅ **Legacy plugins still work** - No immediate action required
414
414
- ⚠️ **Deprecation warnings** - Legacy plugins will show console warnings
415
415
- 📅 **Future removal** - The legacy `runPlugin` and two-parameter `handler(api, params)` will be removed in a future major version
416
416
- 🎯 **Recommended action** - Migrate to single-parameter `PluginContext` handler for new plugins and KV access
417
417
418
-
=== Migration Steps
418
+
###Migration Steps
419
419
420
420
If you have existing plugins using `runPlugin()` or the two-parameter handler, migration is simple:
421
421
@@ -455,7 +455,7 @@ export async function handler(context: PluginContext): Promise<any>
455
455
456
456
```
457
457
458
-
=== Step-by-Step Migration
458
+
###Step-by-Step Migration
459
459
460
460
1.**Remove the `runPlugin()` call** at the bottom of your file
461
461
2.**Rename your function to `handler`** (or create a new handler export)
@@ -464,7 +464,7 @@ export async function handler(context: PluginContext): Promise<any>
464
464
5.**Test your plugin** to ensure it works with the new pattern
465
465
6.**Update your documentation** to reflect the new pattern
466
466
467
-
=== Backwards Compatibility
467
+
###Backwards Compatibility
468
468
469
469
The relayer will automatically detect which pattern your plugin uses:
0 commit comments