thriftrw: go.uber.org/thriftrw/internal/frame Index | Files

package frame

import "go.uber.org/thriftrw/internal/frame"

Package frame provides a framed reader and writer.

Message frames are prefixed with a 4-byte big-endian encoded integer holding the length of the rest of the frame.

Index

Package Files

client.go doc.go reader.go server.go writer.go

type Client Uses

type Client struct {
    sync.Mutex
    // contains filtered or unexported fields
}

Client provides bidirectional outgoing framed communication.

It allows sending framed requests where each request has a corresponding response. Only one active request is allowed at a time. Other requests are blocked while a request is ongoing.

func NewClient Uses

func NewClient(w io.Writer, r io.Reader) *Client

NewClient builds a new Client which uses the given writer to send requests and the given reader to read their responses.

func (*Client) Send Uses

func (c *Client) Send(b []byte) ([]byte, error)

Send sends the given frame and returns its response.

type Handler Uses

type Handler interface {
    // Receives the given framed request and responds to it.
    Handle([]byte) ([]byte, error)
}

Handler handles incoming framed requests.

type Reader Uses

type Reader struct {
    sync.Mutex
    // contains filtered or unexported fields
}

Reader is a reader for framed messages.

func NewReader Uses

func NewReader(r io.Reader) *Reader

NewReader builds a new Reader which reads frames from the given io.Reader.

If the io.Reader is a ReadCloser, its Close method will be called when the frame.Reader is closed.

func (*Reader) Close Uses

func (r *Reader) Close() error

Close closes the given Reader.

func (*Reader) Read Uses

func (r *Reader) Read() ([]byte, error)

Read reads the next frame from the Reader.

type Server Uses

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

Server provides bidirectional incoming framed communication.

It allows receiving framed requests and responding to them.

func NewServer Uses

func NewServer(r io.Reader, w io.Writer) *Server

NewServer builds a new server which reads requests from the given Reader and writes responses to the given Writer.

func (*Server) Serve Uses

func (s *Server) Serve(h Handler) (err error)

Serve serves the given Handler with the Server.

Only one request is served at a time. The server stops handling requests if there is an IO error or an unhandled error is received from the Handler.

This blocks until the server is stopped using Stop.

func (*Server) Stop Uses

func (s *Server) Stop() error

Stop tells the Server that it's okay to stop Serve.

This is a no-op if the server wasn't already running.

type Writer Uses

type Writer struct {
    sync.Mutex
    // contains filtered or unexported fields
}

Writer is a writer for framed messages.

func NewWriter Uses

func NewWriter(w io.Writer) *Writer

NewWriter builds a new Writer which writes frames to the given io.Writer.

If the io.Writer is a WriteCloser, its Close method will be called when the frame.Writer is closed.

func (*Writer) Close Uses

func (w *Writer) Close() error

Close closes the given Writeer.

func (*Writer) Write Uses

func (w *Writer) Write(b []byte) error

Write writes the given frame to the Writer.

Package frame imports 7 packages (graph) and is imported by 9 packages. Updated 2020-01-25. Refresh now. Tools for package owners.