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 ¶
- Variables
- type Client
- type Conn
- func (c *Conn) Begin() (driver.Tx, error)
- func (c *Conn) Close() error
- func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *Conn) Ping(ctx context.Context) error
- func (c *Conn) Prepare(query string) (driver.Stmt, error)
- func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- type Driver
Constants ¶
This section is empty.
Variables ¶
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
Close unsubscribes database changes and closes its local database.
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 ¶
Begin starts and returns a new transaction.
Note: Not implemented. Deprecated: Drivers should implement ConnBeginTx instead (or additionally).
func (*Conn) Close ¶
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 ¶
Ping verifies a connection to the database is still alive, establishing a connection if necessary.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is the MicroDB driver that implements database/sql/driver.
func (*Driver) Open ¶
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.