Documentation
¶
Overview ¶
Package rqloud provides a self-contained replicated application platform combining Tailscale (tsnet) networking with rqlite distributed SQLite.
Index ¶
- func NewAddr(host string, port int) net.Addr
- type Server
- func (s *Server) Close() error
- func (s *Server) DB() (*sql.DB, error)
- func (s *Server) Gorqlite() (*gorqlite.Connection, error)
- func (s *Server) Listen(network, addr string) (net.Listener, error)
- func (s *Server) ListenService(name string, mode tsnet.ServiceMode) (*tsnet.ServiceListener, error)
- func (s *Server) LocalListen(network, addr string) (net.Listener, error)
- func (s *Server) Start() error
- func (s *Server) TS() *tsnet.Server
- func (s *Server) Up(ctx context.Context) error
- func (s *Server) WhoIs(r *http.Request) (*apitype.WhoIsResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Server ¶
type Server struct {
// Hostname is the tsnet hostname for this node.
Hostname string
// Dir is the rqlite data directory (Raft logs, snapshots, SQLite DB).
// Defaults to a directory based on Hostname in os.UserConfigDir().
Dir string
// TSDir is the tsnet configuration directory. If empty, defaults to
// ~/.config/tsnet-<Hostname>/.
// Only used when rqloud creates its own tsnet (i.e. not NewWithTSNet).
TSDir string
// AuthKey is the Tailscale auth key. If empty, interactive login is used.
// Only used when rqloud creates its own tsnet (i.e. not NewWithTSNet).
AuthKey string
// AdvertiseTags is a list of ACL tags to advertise (e.g. "tag:todo").
// Only used when rqloud creates its own tsnet (i.e. not NewWithTSNet).
AdvertiseTags []string
// BootstrapExpect is the number of nodes expected to form the initial
// cluster. When set, nodes use the notify/bootstrap protocol to
// coordinate simultaneous startup. When 0 (default), the first node
// bootstraps solo and others join it.
BootstrapExpect int
// RaftHeartbeat controls the Raft heartbeat timeout. All other Raft
// timeouts (election, lease, commit) are scaled proportionally from
// Raft's default ratios. Higher values reduce idle traffic but
// increase failover time. Defaults to 3s (Raft default is 1s).
RaftHeartbeat time.Duration
// Verbose enables verbose tsnet logging.
Verbose bool
// contains filtered or unexported fields
}
Server is the main rqloud server. It manages a tsnet node, an embedded rqlite store, and provides database access over the tailnet.
func New ¶
func New() *Server
New creates a new rqloud Server that will create and manage its own tsnet node. Call Start() to begin.
func NewWithTSNet ¶
NewWithTSNet creates a new rqloud Server using an existing tsnet.Server. The caller is responsible for the tsnet lifecycle (starting it before calling Start, closing it after calling Close). Hostname is derived from the tsnet server.
func (*Server) DB ¶
DB returns a database/sql handle connected to the local rqlite node. Uses a custom driver that routes all HTTP traffic through tsnet.
func (*Server) Gorqlite ¶
func (s *Server) Gorqlite() (*gorqlite.Connection, error)
Gorqlite returns a native gorqlite connection to the local rqlite node. Uses tsnet's HTTP client so all traffic stays on the tailnet.
func (*Server) ListenService ¶
func (s *Server) ListenService(name string, mode tsnet.ServiceMode) (*tsnet.ServiceListener, error)
ListenService creates a Tailscale Service listener, advertising this node as hosting the named service. See tsnet.Server.ListenService for details.
func (*Server) LocalListen ¶
LocalListen returns a net.Listener on a normal network interface.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
rqloud
command
Command rqloud runs a standalone rqlite cluster over Tailscale.
|
Command rqloud runs a standalone rqlite cluster over Tailscale. |
|
examples
|
|
|
counter
command
Command counter is a minimal rqloud example: a replicated counter with increment/decrement buttons, useful for integration testing.
|
Command counter is a minimal rqloud example: a replicated counter with increment/decrement buttons, useful for integration testing. |
|
hitcount
command
|
|
|
todo
command
Command todo is a demo rqloud application: a per-user todo list served over tsnet.
|
Command todo is a demo rqloud application: a per-user todo list served over tsnet. |