wire

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 1 Imported by: 2 modules, 8 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.

README

Go Wire declarations

Package github.com/Bitspark/bitwire/wire/go, named wire, presents the draft Wire contract. It uses only the Go standard library.

type Wire interface {
    Send(path []string, message Message) error
    Receive(path []string, receiver Receiver) (detach func(), err error)
    Close(code Code, reason string) error
}

wire.go contains the supporting frame, return-address and receiver types. There is no endpoint implementation or published release yet. Existing Nightseam Go implementations require an adoption change or bridge because these declarations introduce distinct named types.

From the repository root, go vet ./... and go test ./... compile the package. No behavioral tests are claimed by this declaration-only scaffold.

Documentation

Overview

Package wire declares the Bitwire access contract, adapted from Nightseam's duplex/go/wire.go and reviewed at 1c63f1c4d7e4b5987d4bd32e294177645c92ed8f. It defines the shared boundary; dispatch, codecs and carriers belong to implementations. Paths are relative sequences of Unicode-scalar strings, without normalization or interpretation of dots, slashes or empty segments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code int

Code is a wire termination code. Meaning and defaults follow the profile.

type Message

type Message struct {
	Frame  ProfileFrame
	Return *ReturnAddress `json:"-"`
}

Message preserves a frame, its local capability and associated received context through routing. Context is established and recognized by the runtime, not inferred from caller-supplied payloads or metadata. Keep the message's contents immutable after Send admits it; implementations may retain them.

type ProfileError

type ProfileError struct {
	Code    string          `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

ProfileError is public error data, without a runtime error dependency. Its fields do not prove that a failed send was never published. That local evidence, when required by value conversion, belongs to the admitting runtime.

type ProfileFrame

type ProfileFrame struct {
	Version     int               `json:"version"`
	Kind        ProfileKind       `json:"kind"`
	ID          string            `json:"id,omitempty"`
	Params      json.RawMessage   `json:"params,omitempty"`
	Result      json.RawMessage   `json:"result,omitempty"`
	Error       *ProfileError     `json:"error,omitempty"`
	Data        json.RawMessage   `json:"data,omitempty"`
	Traceparent string            `json:"traceparent,omitempty"`
	Tracestate  string            `json:"tracestate,omitempty"`
	Meta        map[string]string `json:"meta,omitempty"`
}

ProfileFrame carries a profile frame. The Send path is the request method or event name; keeping it outside this value prevents contradictory names. Payloads retain their JSON representation, including numeric precision. A nil RawMessage means absent; the bytes "null" mean present JSON null. Only fields allowed for Kind may be populated, and Version must be 1. The profile implementation validates those conditions at its boundary.

type ProfileKind

type ProfileKind string

ProfileKind is one of the profile's four frame kinds. Correlation and validation remain the peer's; a wire only carries the frame.

const (
	ProfileRequest  ProfileKind = "request"
	ProfileResponse ProfileKind = "response"
	ProfileEvent    ProfileKind = "event"
	ProfileCancel   ProfileKind = "cancel"
)

type Receiver

type Receiver struct {
	// Namespace matches this path and every descendant. Exact registrations
	// take precedence; otherwise the longest segment prefix wins.
	Namespace bool
	Message   func(path []string, message Message)
	Closed    func(code Code, reason string)
}

Receiver receives deliveries relative to its wire's origin, and an ending. A root owns asynchronous dispatch; composition does not invoke Message itself.

type ReturnAddress

type ReturnAddress struct{ Wire Wire }

ReturnAddress is a local capability with stable pointer identity, even when its Wire implementation is not comparable. Routing must preserve the pointer and any runtime-owned context associated with it. It is never an envelope member. A runtime may use it to retain an event's received context without providing a callable reply or creating a response waiter.

type Wire

type Wire interface {
	Send(path []string, message Message) error
	Receive(path []string, receiver Receiver) (detach func(), err error)
	Close(code Code, reason string) error
}

Wire is an endpoint with an origin. Receive registers an exact relative dispatch path; duplicate registrations are refused. Its detach is idempotent. Send returns when accepted or refused, without running a destination handler on the sender's stack or waiting for its result. Success means admission, not completion of an application effect. A root owns queue bounds, dispatch and carrier closure. A selected view shares that ownership; a mount only owns its routing and registrations.

Jump to

Keyboard shortcuts

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