Documentation
¶
Overview ¶
Package wire is the link between icebath and the code of an extension: frames of the protocol, each the size of its message as a varint and the message in binary on a program's standard input and output, both sides asking and answering the other at once
Index ¶
- Constants
- Variables
- func Answer(reply *protocolv1.Reply, result proto.Message) error
- func Cause(ctx context.Context) context.Context
- func CauseOf(ctx context.Context) int64
- func Denied(format string, args ...any) error
- func Limited(format string, args ...any) error
- func Read(r *bufio.Reader, frame *protocolv1.Frame) error
- func Reply(id int64, result proto.Message, err error) *protocolv1.Frame
- func Serving(ctx context.Context, id int64) context.Context
- func Unavailable(format string, args ...any) error
- func Unknown(format string, args ...any) error
- func Write(w io.Writer, frame *protocolv1.Frame) error
- type Conn
- type Error
- type Handler
Constants ¶
const MaxFrame = 128 << 20
Largest frame either side sends or reads, room for a body of 64 MB and what goes with it
const Version int32 = 2
Version of the protocol this package speaks, which icebath and the extension tell each other on load
Variables ¶
var ErrTooLarge = fmt.Errorf("a frame may be at most %d MB", MaxFrame>>20)
Failure of a frame larger than MaxFrame, which is never sent
Functions ¶
func Answer ¶
func Answer(reply *protocolv1.Reply, result proto.Message) error
Reads the result of a reply into result unless it is nil, an answer of nothing leaving it as it is, and a failure as an *Error
func Cause ¶
Context of the call of this side the request served under ctx was asked as part of, as its cause names it; nil for a request asked on its own, or once that call ended
func CauseOf ¶
Id of the request of the other side ctx serves on a link with no Conn, which a request asked under it names as its cause; 0 for none
func Read ¶
func Read(r *bufio.Reader, frame *protocolv1.Frame) error
Reads one frame, io.EOF when the stream ended before it began
func Reply ¶
Reply of the request with the id: its error, or its result, nothing answering with google.protobuf.Empty
func Serving ¶
Context serving the request of the other side with the id on a link with no Conn, such as that of a module, so a request asked under it names it as its cause
func Unavailable ¶
Refusal of a request nothing can answer now, such as a question in a session nobody watches
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Connection over one stream of frames: requests sent and answered both ways at once, each request served on its own goroutine and the notices one after another in the order they came
func NewConn ¶
Connection reading frames from in and writing them to out, serving the other side's requests with handle
func (*Conn) Call ¶
Sends a request, its id assigned here, and waits for its reply, whose result is read into result unless it is nil. A request asked as ctx serves one of the other side names that one as its cause, and one whose context serves none names the one request of the other side served now while there is one alone. A reply of a failure returns an *Error, and a context that ends first tells the other side to stop
type Error ¶
type Error struct {
Message string
Code protocolv1.Code
}
Failure of a request, as the side that served it said it