For the complete documentation index, see llms.txt. This page is also available as Markdown.
Adapters
Adapters are components responsible for handling I/O processes and external integrations. They serve as the bridge between your business logic and external systems such as databases, APIs, file systems, or cache stores.
Purpose
Adapters abstract away the implementation details of external dependencies, allowing:
Adapters SHOULD be built with interchangeability in mind. Define shared interfaces in src/types.ts so that multiple adapters can implement the same contract.
Example: Storage Interface
Memory Storage Adapter
Here's a simple in-memory storage adapter implementation, useful for testing or development.
Directory Structure
Implementation: component.ts
Redis Storage Adapter
Here's a production-ready Redis adapter that demonstrates lifecycle management.
Implementation: component.ts
Error Handling: errors.ts
Database Adapter Example
Here's an example of a PostgreSQL database adapter.
Lifecycle Methods
WKC provides special lifecycle methods that are automatically called:
[Lifecycle.ComponentStarted] or [START_COMPONENT] - Called when the service starts
[Lifecycle.ComponentStopped] or [STOP_COMPONENT] - Called when the service shuts down