Skip to content

Commit

Permalink
Merge pull request #908 from Albitko/feature-connection-string
Browse files Browse the repository at this point in the history
dev: Implement String() for Connection and/or configs for print debug info on fails
  • Loading branch information
asmyasnikov authored Dec 25, 2023
2 parents 10479c6 + 94be7b0 commit 17d223e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* Refactored config prefix in metrics
* Removed excess status labels from metrics

## v3.54.3
* Implement `String` interface for `Driver` struct

## v3.54.2
* Added context to some internal methods for better tracing
* Added `trace.FunctionID` helper and `FunctionID` field to trace start info's
Expand Down
12 changes: 12 additions & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ydb
import (
"context"
"errors"
"fmt"
"os"
"sync"

Expand Down Expand Up @@ -210,6 +211,17 @@ func (d *Driver) Topic() topic.Client {
return d.topic
}

// String returns string representation of Driver
func (d *Driver) String() string {
return fmt.Sprintf(
"Driver{User: %s, Endpoint: %s, Database: %s, IsSecure %t}",
d.userInfo.User,
d.config.Endpoint(),
d.config.Database(),
d.config.Secure(),
)
}

// Open connects to database by DSN and return driver runtime holder
//
// DSN accept Driver string like
Expand Down

0 comments on commit 17d223e

Please sign in to comment.