π SmartPlug Test Scenario
This is the simplest working SmartPlug based on
the PlugKit protocol β a minimal but functional
demonstration of plugin-to-host communication.
π§ Concept
The goal of this test scenario is to verify that a single message can be sent
from a host to a plug, and that the plug can respond correctly β exactly once.
No loops, no protocol magic. Just one roundtrip. Clean and minimal.
This is useful as a smoke test for your PlugKit-compatible infrastructure or as
a starting point for implementing more complex plugins.
π Project structure
.
βββ plug/ # π The plug binary β implements RawStreamPlug
βββ client/ # π§βπ» The host β sends a single message to the plug
βββ shared/ # π¦ Shared types and helpers β messages, CBOR encoding, codes, etc.
- The plug listens for a single
Envelope message, processes it, and
responds.
- The host sends one message, waits for the reply, and exits.
- The shared package contains the agreed contract between plug and host (
message types, payload encoding, etc).
β
What it demonstrates
- π― PlugKit-compatible message envelope handling (CBOR-encoded)
- π One-shot request/response cycle
- π Bidirectional stdio stream between host and plug
π Running the scenario
You can run the test by building both binaries.
The host will:
-
Start the plug process
-
Send a single CBOR-encoded message
-
Wait for the plug to respond
-
Print the response and exit
The plug will:
-
Wait for a message
-
Process it
-
Reply
-
Shut down
This is a great minimal example to understand the lifecycle of a SmartPlug π β
message in, response out, context-aware shutdown, and no extra fluff.
Enjoy plugging!