brmcptest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: ISC Imports: 6 Imported by: 0

Documentation

Overview

Package brmcptest provides an in-memory private message fabric so brmcp endpoints (routers, harnesses, bridges) can be exercised end to end without a relay.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Text

func Text(res *mcp.CallToolResult) string

Text concatenates the text content of a tool result.

func UID

func UID(n int) string

UID returns a deterministic 64-hex Bison Relay uid built from the low four bits of n, e.g. UID(1) is the string of 64 '1' characters.

Types

type Fabric

type Fabric struct {
	// contains filtered or unexported fields
}

Fabric delivers private messages between test endpoints the way the relay would: asynchronously, attributed to the sending uid.

func NewFabric

func NewFabric() *Fabric

func (*Fabric) Attach

func (f *Fabric) Attach(uid string, deliver func(fromUID, text string))

Attach registers deliver as the endpoint living at uid. Every PM sent to uid is delivered as deliver(fromUID, text) on its own goroutine. A router's HandlePM is a valid deliver function.

func (*Fabric) Close

func (f *Fabric) Close()

Close stops delivery and closes every fabric-built router.

func (*Fabric) NewRouter

func (f *Fabric) NewRouter(uid string, cfg brmcp.RouterConfig) *brmcp.Router

NewRouter builds a router living at uid on this fabric: cfg.Sender is replaced with the fabric's sender for uid and inbound PMs feed the router's HandlePM. The router is closed with the fabric.

func (*Fabric) Sender

func (f *Fabric) Sender(fromUID string) brmcp.PMSender

Sender returns the PM sender for an endpoint living at fromUID. PMs to unknown peers (or after Close) are dropped, like a relay without the recipient.

func (*Fabric) Sent

func (f *Fabric) Sent() int64

Sent reports how many PMs crossed the fabric, for chunk-count assertions.

type SenderFunc

type SenderFunc func(ctx context.Context, peer, text string) error

SenderFunc adapts a function to brmcp.PMSender.

func (SenderFunc) SendPM

func (f SenderFunc) SendPM(ctx context.Context, peer, text string) error

SendPM implements brmcp.PMSender.

Jump to

Keyboard shortcuts

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