Documentation ¶
Index ¶
- Constants
- Variables
- func CompileMatch(s string) (*regexp.Regexp, error)
- func Error(w http.ResponseWriter, r *http.Request, err error, code int)
- func ReadPosMapFrom(r io.Reader) (map[string]ltx.Pos, error)
- func WritePosMapTo(w io.Writer, m map[string]ltx.Pos) error
- type Client
- func (c *Client) AcquireHaltLock(ctx context.Context, primaryURL string, nodeID uint64, name string, ...) (_ *litefs.HaltLock, retErr error)
- func (c *Client) Commit(ctx context.Context, primaryURL string, nodeID uint64, name string, ...) error
- func (c *Client) Export(ctx context.Context, primaryURL, name string) (io.ReadCloser, error)
- func (c *Client) Handoff(ctx context.Context, primaryURL string, nodeID uint64) error
- func (c *Client) Import(ctx context.Context, primaryURL, name string, r io.Reader) error
- func (c *Client) Info(ctx context.Context, baseURL string) (info litefs.NodeInfo, err error)
- func (c *Client) Promote(ctx context.Context, baseURL string) error
- func (c *Client) ReleaseHaltLock(ctx context.Context, primaryURL string, nodeID uint64, name string, ...) error
- func (c *Client) Stream(ctx context.Context, primaryURL string, nodeID uint64, ...) (litefs.Stream, error)
- type ProxyServer
- type RemoteTx
- type Server
- type Stream
Constants ¶
const ( DefaultPollTXIDInterval = 1 * time.Millisecond DefaultPollTXIDTimeout = 5 * time.Second DefaultPrimaryRedirectTimeout = 5 * time.Second DefaultMaxLag = 10 * time.Second DefaultCookieExpiry = 5 * time.Minute DefaultReadTimeout = 0 DefaultReadHeaderTimeout = 10 * time.Second DefaultWriteTimeout = 0 DefaultIdleTimeout = 30 * time.Second )
const ( HeaderNodeID = "Litefs-Id" HeaderClusterID = "Litefs-Cluster-Id" )
HTTP headers
const (
DefaultAddr = ":20202"
)
Default settings
const (
HeartbeatInterval = time.Second
)
const TXIDCookieName = "__txid"
TXIDCookieName is the name of the cookie that tracks transaction ID.
Variables ¶
var ErrProxyServerClosed = fmt.Errorf("canceled, proxy server closed")
var ErrServerClosed = fmt.Errorf("canceled, http server closed")
Functions ¶
func CompileMatch ¶ added in v0.4.0
CompileMatch returns a regular expression on a simple asterisk-only wildcard.
Types ¶
type Client ¶
Client represents an client for a streaming LiteFS HTTP server.
func (*Client) AcquireHaltLock ¶ added in v0.4.0
func (*Client) Export ¶ added in v0.4.0
Export downloads a SQLite database from the remote LiteFS server. Returned reader must be closed by caller.
func (*Client) Handoff ¶ added in v0.4.0
Handoff requests that the current primary handoff leadership to a specific node.
func (*Client) Import ¶ added in v0.3.0
Import creates or replaces a SQLite database on the remote LiteFS server.
func (*Client) Promote ¶ added in v0.4.0
Promote attempts to promote the current node to be the primary.
func (*Client) ReleaseHaltLock ¶ added in v0.4.0
type ProxyServer ¶ added in v0.4.0
type ProxyServer struct { // Hostport of application that is being proxied. Target string // Name of database to use for TXID consistency tracking. DBName string // Bind address that the proxy listens on. Addr string // List of path expressions that will be passed through if matched. Passthroughs []*regexp.Regexp // List of path expressions that will always be redirected to the primary. AlwaysForward []*regexp.Regexp // If true, add verbose debug logging. Debug bool // Interval & timeout for ensuring read consistency. PollTXIDInterval time.Duration PollTXIDTimeout time.Duration PrimaryRedirectTimeout time.Duration // Maximum allowable lag before the health endpoint returns an error code. MaxLag time.Duration // Time before cookie expires on client. CookieExpiry time.Duration // HTTP server timeouts ReadTimeout time.Duration ReadHeaderTimeout time.Duration WriteTimeout time.Duration IdleTimeout time.Duration HTTPTransport *http.Transport // contains filtered or unexported fields }
ProxyServer represents a thin proxy in front of the user's application that can handle primary redirection and TXID consistency on replicas.
Exported fields must be set before calling Listen().
func NewProxyServer ¶ added in v0.4.0
func NewProxyServer(store *litefs.Store) *ProxyServer
NewProxyServer returns a new instance of ProxyServer.
func (*ProxyServer) Close ¶ added in v0.4.0
func (s *ProxyServer) Close() (err error)
func (*ProxyServer) Listen ¶ added in v0.4.0
func (s *ProxyServer) Listen() (err error)
func (*ProxyServer) Port ¶ added in v0.4.0
func (s *ProxyServer) Port() int
Port returns the port the listener is running on.
func (*ProxyServer) Serve ¶ added in v0.4.0
func (s *ProxyServer) Serve()
func (*ProxyServer) URL ¶ added in v0.4.0
func (s *ProxyServer) URL() string
URL returns the full base URL for the running server.
type RemoteTx ¶ added in v0.4.0
type RemoteTx struct {
// contains filtered or unexported fields
}
RemoteTx represents a remote transaction created by Client.Begin().
func (*RemoteTx) Commit ¶ added in v0.4.0
Commit send the LTX data from r to the remote primary for commit.
func (*RemoteTx) PreApplyChecksum ¶ added in v0.4.0
PreApplyChecksum returns checksum of the database before the transaction is applied.
type Server ¶
type Server struct { // Time allowed to write a single LTX snapshot in the stream. // This is meant to prevent slow snapshot downloads backing up the primary. SnapshotTimeout time.Duration // contains filtered or unexported fields }
Server represents an HTTP API server for LiteFS.
type Stream ¶ added in v0.5.0
type Stream struct { io.ReadCloser // contains filtered or unexported fields }
Stream is a wrapper around the stream response body.