Documentation
¶
Overview ¶
* Copyright 2023 https://github.com/superfly * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Modifications by https://github.com/stephen.
Index ¶
- Constants
- type CheckRestoreDatabaseOutput
- type Client
- func (c *Client) CheckRestoreDatabase(ctx context.Context, database string, ro RestoreOption) (*CheckRestoreDatabaseOutput, error)
- func (c *Client) CreateCluster(ctx context.Context, name, region string) (*Cluster, error)
- func (c *Client) DeleteCluster(ctx context.Context, name string) error
- func (c *Client) DeleteDB(ctx context.Context, database string) error
- func (c *Client) Do(ctx context.Context, method string, u url.URL, input, output any) error
- func (c *Client) ExportDatabase(ctx context.Context, database, format string) (io.ReadCloser, error)
- func (c *Client) HWM(ctx context.Context) (map[string]ltx.TXID, error)
- func (c *Client) ImportDatabase(ctx context.Context, database string, r io.Reader) (ltx.TXID, error)
- func (c *Client) Info(ctx context.Context, database string, all bool) (*DBInfoOutput, error)
- func (c *Client) ListClusters(ctx context.Context, input *ListClustersInput) (*ListClustersOutput, error)
- func (c *Client) Pos(ctx context.Context) (map[string]ltx.Pos, error)
- func (c *Client) Regions(ctx context.Context) ([]string, error)
- func (c *Client) RestoreDatabase(ctx context.Context, database string, ro RestoreOption) (ltx.TXID, error)
- type Cluster
- type DBInfoOutput
- type DBInfoRestorablePath
- type Error
- type ListClustersInput
- type ListClustersOutput
- type RestoreOption
Constants ¶
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) CheckRestoreDatabase ¶
func (c *Client) CheckRestoreDatabase(ctx context.Context, database string, ro RestoreOption) (*CheckRestoreDatabaseOutput, error)
CheckRestoreDatabase verifies that the requested restore can be completed and returns the txid/timestamp that will be restored. A cluster-scoped authentication token with write permissions is required.
func (*Client) CreateCluster ¶
CreateCluster creates a new cluster in a given region. An org-scoped authentication token with write permissions is required.
func (*Client) DeleteCluster ¶
DeleteCluster permanently deletes an existing cluster. An org-scoped authentication token with write permissions is required.
func (*Client) DeleteDB ¶
DeleteDB permanently deletes a db from a cluster. An org-scoped authentication token with write permissions is required.
func (*Client) ExportDatabase ¶
func (c *Client) ExportDatabase(ctx context.Context, database, format 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 ¶
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 ¶
Pos returns a map of database names with their current replication position. A cluster-scoped authentication token with read permissions is required.
func (*Client) RestoreDatabase ¶
func (c *Client) RestoreDatabase(ctx context.Context, database string, ro RestoreOption) (ltx.TXID, error)
RestoreDatabase reverts the database to the state by timestamp or txid. 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 DBInfoOutput ¶
type DBInfoOutput struct {
Name string `json:"name"`
RestorablePaths []DBInfoRestorablePath `json:"restorablePaths"`
}
type DBInfoRestorablePath ¶
type ListClustersInput ¶
type ListClustersOutput ¶
type RestoreOption ¶
type RestoreOption func(*restoreOptions)
func RestoreByTXID ¶
func RestoreByTXID(txid string) RestoreOption
RestoreByTXID tries to restore to the txid, if available.
func RestoreByTimestamp ¶
func RestoreByTimestamp(timestamp time.Time) RestoreOption
RestoreByTimestamp tries to restore to the timestamp, or closest point earlier than the timestamp.