Skip to content

Commit

Permalink
Some more docs
Browse files Browse the repository at this point in the history
Signed-off-by: Cole Miller <[email protected]>
  • Loading branch information
cole-miller committed Oct 18, 2024
1 parent 58fc6e5 commit cf3c248
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion client/database_store.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//go:build !nosqlite3
// +build !nosqlite3

package client
Expand Down
1 change: 0 additions & 1 deletion client/leader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package client_test
import (
"context"
"fmt"
"reflect"
"testing"
"time"

Expand Down
9 changes: 7 additions & 2 deletions internal/protocol/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const MaxConcurrentLeaderConns int64 = 10
// DialFunc is a function that can be used to establish a network connection.
type DialFunc func(context.Context, string) (net.Conn, error)

// LeaderTracker remembers the address of the cluster leader, and possibly
// holds a reusable connection to it.
type LeaderTracker struct {
mu sync.RWMutex
lastKnownLeaderAddr string
Expand Down Expand Up @@ -80,8 +82,8 @@ type Connector struct {
log logging.Func // Logging function.
}

// NewConnector returns a new connector that can be used by a dqlite driver to
// create new clients connected to a leader dqlite server.
// NewConnector returns a Connector that will connect to the current cluster
// leader.
func NewLeaderConnector(store NodeStore, config Config, log logging.Func) *Connector {
if config.Dial == nil {
config.Dial = Dial
Expand Down Expand Up @@ -110,6 +112,8 @@ func NewLeaderConnector(store NodeStore, config Config, log logging.Func) *Conne
}
}

// NewDirectConnector returns a Connector that will connect to the node with
// the given ID and address.
func NewDirectConnector(id uint64, address string, config Config, log logging.Func) *Connector {
if config.Dial == nil {
config.Dial = Dial
Expand Down Expand Up @@ -139,6 +143,7 @@ func NewDirectConnector(id uint64, address string, config Config, log logging.Fu
}
}

// Connect opens a new Protocol based on the Connector's configuration.
func (c *Connector) Connect(ctx context.Context) (*Protocol, error) {
if c.nodeID != 0 {
ctx, cancel := context.WithTimeout(ctx, c.config.AttemptTimeout)
Expand Down

0 comments on commit cf3c248

Please sign in to comment.