client

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Unlicense Imports: 13 Imported by: 5

Documentation

Overview

Package client represents a MicroDB client

Package client represents a MicroDB client

Package client represents a MicroDB client

Package client represents a MicroDB client.

Package client represents a MicroDB client.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNATSError represents the client lost connection to NATS.
	ErrNATSError = errors.New("NATS connection error")

	// ErrLocalDBError represents the client lost connection to local database or it is not ready
	// for operations yet.
	ErrLocalDBError = errors.New("local sqlite3 database connection error")
)

Functions

This section is empty.

Types

type Client added in v0.1.2

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

Client represents a microDB client.

func Connect added in v0.1.2

func Connect(natsHost, natsPort, natsClientID, natsClusterID string, tables ...string) (*Client, error)

Connect creates a microDB client.

func (*Client) Close added in v0.1.2

func (c *Client) Close() error

Close unsubscribes database changes and closes its local database.

func (*Client) Execute added in v0.1.2

func (c *Client) Execute(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Execute executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*Client) Query added in v0.1.2

func (c *Client) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Query executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

type Conn

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

Conn is a connection to MicroDB system. It is not used concurrently by multiple goroutines.

Conn is assumed to be stateful.

func (*Conn) Begin

func (c *Conn) Begin() (driver.Tx, error)

Begin starts and returns a new transaction.

Note: Not implemented. Deprecated: Drivers should implement ConnBeginTx instead (or additionally).

func (*Conn) Close

func (c *Conn) Close() error

Close invalidates and potentially stops any current prepared statements and transactions, marking this connection as no longer in use.

Because the sql package maintains a free pool of connections and only calls Close when there's a surplus of idle connections, it shouldn't be necessary for drivers to do their own connection caching.

Drivers must ensure all network calls made by Close do not block indefinitely (e.g. apply a timeout).

func (*Conn) ExecContext

func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)

ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*Conn) Ping

func (c *Conn) Ping(ctx context.Context) error

Ping verifies a connection to the database is still alive, establishing a connection if necessary.

func (*Conn) Prepare

func (c *Conn) Prepare(query string) (driver.Stmt, error)

Prepare returns a prepared statement, bound to this connection.

Note: Not implemented.

func (*Conn) QueryContext

func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)

QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

type Driver

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

Driver is the MicroDB driver that implements database/sql/driver.

func (*Driver) Open

func (d *Driver) Open(name string) (driver.Conn, error)

Open returns a new connection to the database.

The name is a string in a driver-specific format. dsn format:

natsClientID=... natsHost=... natsPort=... tables=...,...

Open may return a cached connection (one previously closed), but doing so is unnecessary; the sql package maintains a pool of idle connections for efficient re-use.

This method blocks until the nats connection is ready.

The returned connection is only used by one goroutine at a time.

Jump to

Keyboard shortcuts

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