irpc

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package irpc provides small postcard-framed RPC helpers for iroh streams.

The Go API is not stable before v1 and may change in any v0 release.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call[Req, Resp any](ctx context.Context, conn *iroh.Conn, req Req, maxMessageSize int) (iter.Seq2[Resp, error], error)

Call opens one stream on conn, sends req, and yields the response stream.

Types

type Handler

type Handler[Req, Resp any] struct {
	// MaxMessageSize limits one postcard frame body. The zero value uses 16 MiB.
	MaxMessageSize int
	// Handle handles one request and may send zero or more responses.
	Handle func(context.Context, Req, *Responder[Resp]) error
}

Handler handles typed requests on an iroh connection.

func (Handler[Req, Resp]) Accept

func (h Handler[Req, Resp]) Accept(ctx context.Context, conn *iroh.Conn) error

Accept handles streams opened on conn until ctx is cancelled or conn closes.

type Responder

type Responder[Resp any] struct {
	// contains filtered or unexported fields
}

Responder sends typed responses for one request.

func (*Responder[Resp]) Error

func (r *Responder[Resp]) Error(err error) error

Error sends err to the caller.

func (*Responder[Resp]) Send

func (r *Responder[Resp]) Send(resp Resp) error

Send sends resp to the caller.

Jump to

Keyboard shortcuts

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