http

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAddr = ":20202"
)

Default settings

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, r *http.Request, err error, code int)

func ReadPosMapFrom

func ReadPosMapFrom(r io.Reader) (map[uint32]litefs.Pos, error)

func WritePosMapTo

func WritePosMapTo(w io.Writer, m map[uint32]litefs.Pos) error

Types

type Client

type Client struct {
	// Underlying HTTP client
	HTTPClient *http.Client
}

Client represents an client for a streaming LiteFS HTTP server.

func NewClient

func NewClient() *Client

NewClient returns an instance of Client.

func (*Client) Stream

func (c *Client) Stream(ctx context.Context, rawurl string, posMap map[uint32]litefs.Pos) (litefs.StreamReader, error)

Stream returns a snapshot and continuous stream of WAL updates.

type Server

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

Server represents an HTTP API server for LiteFS.

func NewServer

func NewServer(store *litefs.Store, addr string) *Server

func (*Server) Close

func (s *Server) Close() (err error)

func (*Server) Listen

func (s *Server) Listen() (err error)

func (*Server) Port

func (s *Server) Port() int

Port returns the port the listener is running on.

func (*Server) Serve

func (s *Server) Serve()

func (*Server) URL

func (s *Server) URL() string

URL returns the full base URL for the running server.

type StreamReader

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

StreamReader represents a stream of changes from a primary server.

func (*StreamReader) Close

func (r *StreamReader) Close() (err error)

Close closes the underlying reader.

func (*StreamReader) NextFrame

func (r *StreamReader) NextFrame() (litefs.StreamFrame, error)

NextFrame returns the frame from the underlying reader.. This call will block until a record is available. After calling NextFrame(), the frame payload can be read by calling Read() until io.EOF is reached.

func (*StreamReader) Read

func (r *StreamReader) Read(p []byte) (n int, err error)

Read reads bytes of the current payload into p. Only valid after a successful call to Next(). On io.EOF, call Next() again to begin reading next record.

Jump to

Keyboard shortcuts

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