Help us shape the future of Go! Take the 2026 Go Developer Survey

lfsc

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

LiteFS Cloud Go Client GitHub release (latest by date) GitHub

This project is a thin wrapper for connecting to LiteFS Cloud. Most methods require either an org-scoped or cluster-scoped auth token. The API on this package is not considered stable until it reaches v1.0.0.

Usage

To use the library, instantiate a Client and set the auth token if your method requires it:

client := lfsc.NewClient()
client.Token = os.Getenv("LITEFS_CLOUD_TOKEN")

Documentation

Index

Constants

View Source
const DefaultURL = "https://litefs.fly.io"

DefaultURL is the default URL set by NewClient().

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Base URL of the remote LiteFS Cloud service.
	URL string

	// Authentication token. Required for most API calls.
	Token string
}

Client represents a client for connecting to LiteFS Cloud.

func NewClient

func NewClient() *Client

NewClient returns a new instance of Client with the default URL.

func (*Client) CreateCluster

func (c *Client) CreateCluster(ctx context.Context, name, region string) (*Cluster, error)

CreateCluster creates a new cluster in a given region. An org-scoped authentication token with write permissions is required.

func (*Client) DeleteCluster

func (c *Client) DeleteCluster(ctx context.Context, name string) error

DeleteCluster permanently deletes an existing cluster. An org-scoped authentication token with write permissions is required.

func (*Client) ExportDatabase

func (c *Client) ExportDatabase(ctx context.Context, database string) (io.ReadCloser, error)

ExportDatabase returns a reader that contains the current database state. A cluster-scoped authentication token with read permissions is required.

func (*Client) HWM

func (c *Client) HWM(ctx context.Context) (map[string]ltx.TXID, error)

HWM returns a map of database names with their current high-water mark. A cluster-scoped authentication token with read permissions is required.

func (*Client) ImportDatabase

func (c *Client) ImportDatabase(ctx context.Context, database string, r io.Reader) (ltx.TXID, error)

ImportDatabase creates a new database with the SQLite database contained in r. A cluster-scoped authentication token with write permissions is required.

func (*Client) ListClusters

func (c *Client) ListClusters(ctx context.Context, input *ListClustersInput) (*ListClustersOutput, error)

ListClusters returns a list of clusters for the current organization. An org-scoped authentication token with read permissions is required.

func (*Client) Pos

func (c *Client) Pos(ctx context.Context) (map[string]ltx.Pos, error)

Pos returns a map of database names with their current replication position. A cluster-scoped authentication token with read permissions is required.

func (*Client) Regions added in v0.1.1

func (c *Client) Regions(ctx context.Context) ([]string, error)

Regions returns a list of available LiteFS Cloud regions.

func (*Client) RestoreDatabaseToTimestamp

func (c *Client) RestoreDatabaseToTimestamp(ctx context.Context, database string, timestamp time.Time) (ltx.TXID, error)

RestoreDatabaseToTimestamp reverts the database to the state closest to the given timestamp. A cluster-scoped authentication token with write permissions is required.

type Cluster

type Cluster struct {
	OrgID     int       `json:"orgID"`
	Name      string    `json:"name"`
	Region    string    `json:"region"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Cluster represents a grouping of databases in LiteFS Cloud.

type Error

type Error struct {
	Code    string `json:"code"`
	Message string `json:"error"`
}

Error represents an error code & message returned from LiteFS Cloud.

func (*Error) Error

func (e *Error) Error() string

Error returns a string-formatted message. Implements the error interface.

type ListClustersInput

type ListClustersInput struct {
	Offset int `json:"offset"`
	Limit  int `json:"limit"`
}

type ListClustersOutput

type ListClustersOutput struct {
	Offset   int        `json:"offset"`
	Limit    int        `json:"limit"`
	Total    int        `json:"total"`
	Clusters []*Cluster `json:"clusters"`
}

Jump to

Keyboard shortcuts

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