0-smartplug-test-basic/

directory
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2025 License: MIT

README ΒΆ

πŸ”Œ 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:

  1. Start the plug process

  2. Send a single CBOR-encoded message

  3. Wait for the plug to respond

  4. Print the response and exit

The plug will:

  1. Wait for a message

  2. Process it

  3. Reply

  4. 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!

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL