Help us shape the future of Go! Take the 2026 Go Developer Survey

echo-channel

command
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Command echo-channel is the reference rysh channel plugin (docs/plugin-authoring.md).

It speaks the stdio transport: newline-delimited JSON-RPC 2.0 on stdin/stdout, exactly what rysh's PluginSupervisor drives (internal/channels/plugin/stdio.go is the core-side counterpart). The nats transport exists too (subjects rysh.channel.plugin.{name}.*), but stdio is the right starting point for authors: no bus credentials, no extra dependency — this file imports only the standard library, so it can be copied out of the rysh repo and built standalone.

"Echo" semantics: an echo channel has no real platform behind it, so the only external stimulus is rysh sending a message. Every outbound `send` is reflected straight back as an `inbound` notification on the same thread — which exercises both directions of the wire contract and makes a humanoid literally talk to itself.

Wire contract (core → plugin requests, plugin replies by id):

start(ChannelConfig)  begin "connecting"; reply {ok}; then push status + inbounds
send(OutboundMessage) deliver to the platform; reply {ok} or an error object
status()              reply the current ChannelStatus
stop()                graceful shutdown; reply {ok}, then exit 0

Core → plugin notification (no id, no reply):

setReplyMode({op,mode})

Plugin → core notifications:

ready()                 REQUIRED once at startup — core's spawn blocks on it
inbound(InboundMessage) a message arriving from the platform
status(ChannelStatus)   connection-state updates (core caches the last one)

Rules a plugin must obey:

  • stdout is the protocol. One JSON object per line, nothing else — log to stderr (core forwards it).
  • Emit `ready` promptly: core kills the process after its ready timeout (10s default).
  • Exit 0 on `stop` and on stdin EOF. Any other exit is treated as a crash: core restarts with backoff and eventually circuit-breaks.

Jump to

Keyboard shortcuts

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